line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GetRc; |
2
|
|
|
|
|
|
|
require 5.002; |
3
|
|
|
|
|
|
|
require Exporter; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#use strict; |
6
|
4
|
|
|
4
|
|
16032
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
415
|
|
7
|
4
|
|
|
4
|
|
23
|
use File::Basename; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
488
|
|
8
|
4
|
|
|
4
|
|
7087
|
use UNIVERSAL qw(isa); |
|
4
|
|
|
|
|
61
|
|
|
4
|
|
|
|
|
19
|
|
9
|
4
|
|
|
4
|
|
1997
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
424
|
|
10
|
4
|
|
|
4
|
|
3903
|
use IO::File; |
|
4
|
|
|
|
|
53382
|
|
|
4
|
|
|
|
|
720
|
|
11
|
4
|
|
|
4
|
|
35
|
use Fcntl qw(:DEFAULT :flock); # import LOCK_* constants |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
16165
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
### my initial version was 0.13 |
15
|
|
|
|
|
|
|
### version 0.20 is first OO ( Object Oriented of course ) |
16
|
|
|
|
|
|
|
$VERSION = '0.23'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Items to export into callers namespace by default |
21
|
|
|
|
|
|
|
@EXPORT = qw(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Other items we are prepared to export if requested |
24
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
2
|
|
|
2
|
1
|
151
|
my $type = shift; |
29
|
2
|
|
33
|
|
|
16
|
my $class = ref($type) || $type; |
30
|
2
|
50
|
|
|
|
9
|
croak "Usage $class->new (filename)" if ( @_ != 1 ) ; |
31
|
2
|
|
|
|
|
6
|
my $self = {}; |
32
|
2
|
|
|
|
|
7
|
bless $self, $class; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
19
|
$self->{'filename'} = shift; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
13
|
$self->_init; |
37
|
2
|
|
|
|
|
12
|
$self->_find_file; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
17
|
return($self); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _find_file { |
43
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
4
|
foreach ( @{$self->{'find_path'}} ) { |
|
2
|
|
|
|
|
6
|
|
46
|
2
|
50
|
|
|
|
24
|
last if ( $self->{'filename'} =~ /^\//); |
47
|
0
|
0
|
|
|
|
0
|
$self->{'filename'} = "$_".$self->{'filename'},last if ( -e "$_".$self->{'filename'}) ; |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
17
|
$self->dprint("file is " . $self->{'filename'}); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _init { |
54
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
55
|
2
|
|
|
|
|
87
|
my ( $filename,$dirname ) = fileparse($0); |
56
|
2
|
|
|
|
|
8
|
$self->{'ifs'} = '\s*=\s*'; |
57
|
2
|
|
|
|
|
8
|
$self->{'ofs'} = ' = '; |
58
|
2
|
|
|
|
|
6
|
$self->{'debug'} = 0; |
59
|
2
|
|
|
|
|
5
|
$self->{'multivalues'} = 1; |
60
|
2
|
|
|
|
|
5
|
$self->{'lock'} = 1; |
61
|
2
|
|
|
|
|
5
|
$self->{'locktimeout'} = 15; |
62
|
2
|
|
|
|
|
3080
|
$self->{'find_path'} = [ |
63
|
|
|
|
|
|
|
"./", |
64
|
|
|
|
|
|
|
(getpwuid($>))[7]."/", |
65
|
|
|
|
|
|
|
$dirname, |
66
|
|
|
|
|
|
|
"../", |
67
|
|
|
|
|
|
|
"/usr/local/etc/", |
68
|
|
|
|
|
|
|
]; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
9
|
bless $self->{'find_path'}; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
6
|
return($self); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub writerc ($\%) { |
76
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
77
|
1
|
|
|
|
|
3
|
local *h_input = shift; |
78
|
1
|
|
|
|
|
2
|
my ($rc); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
10
|
$self->dprint("join to writerc"); |
81
|
|
|
|
|
|
|
### locking ? uff .. this a bit messy code |
82
|
1
|
50
|
|
|
|
4
|
if ( $self->{'lock'} ) { |
83
|
1
|
|
|
|
|
3
|
eval { |
84
|
1
|
|
|
0
|
|
33
|
local $SIG{ALRM} = sub { die "File lock timeouted\n" }; |
|
0
|
|
|
|
|
0
|
|
85
|
1
|
|
|
|
|
174
|
alarm($self->{'locktimeout'}); |
86
|
1
|
|
|
|
|
8
|
$self->dprint("openning file ".$self->{'filename'}); |
87
|
1
|
|
|
|
|
11
|
$rc = new IO::File $self->{'filename'}, O_CREAT|O_WRONLY|O_TRUNC; |
88
|
1
|
50
|
|
|
|
64832
|
croak "Can't open file\n" unless ( defined $rc ); |
89
|
1
|
|
|
|
|
18
|
$self->dprint("locking file ".$self->{'filename'}); |
90
|
1
|
|
|
|
|
15
|
flock($rc,LOCK_EX); |
91
|
1
|
|
|
|
|
7
|
$self->dprint($self->{'filename'} . " locked"); |
92
|
1
|
|
|
|
|
33
|
alarm(0); |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
1
|
50
|
|
|
|
6
|
if ($@) { |
96
|
0
|
0
|
|
|
|
0
|
return(-3),$self->dprint("File lock timeouted\n") if $@ eq "File lock timeouted\n"; |
97
|
0
|
0
|
|
|
|
0
|
return(-4),$self->dprint("Can't open file ".$self->{'filename'}) if $@ eq "Can't open file\n"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} else { |
101
|
0
|
|
|
|
|
0
|
$self->dprint("openning file ".$self->{'filename'}); |
102
|
0
|
|
|
|
|
0
|
$rc = new IO::File $self->{'filename'}, O_CREAT|O_WRONLY|O_TRUNC; |
103
|
0
|
0
|
|
|
|
0
|
croak "Can't open file ".$self->{'filename'}." : $!" unless ( defined $rc ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
5
|
my $separator = $self->{'ofs'}; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
11
|
while (($key,$value) = each %h_input) { |
109
|
4
|
|
|
|
|
43
|
print $rc "$key${separator}$value\n"; |
110
|
4
|
|
|
|
|
719
|
print "HEY: $key => $value\n"; |
111
|
|
|
|
|
|
|
} |
112
|
1
|
50
|
|
|
|
60
|
flock($rc,LOCK_UN),$self->dprint( $self->{'filename'} ." unlocked") if ( $self->{'lock'} ); |
113
|
1
|
|
|
|
|
20
|
$rc->close; |
114
|
1
|
50
|
|
|
|
40
|
croak "Can't close file ".$self->{'filename'} .": $1" if $?; |
115
|
1
|
|
|
|
|
11
|
$self->dprint( $self->{'filename'} ." closed"); |
116
|
1
|
|
|
|
|
10
|
return(0); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub getrc ($\%){ |
121
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
122
|
0
|
|
|
|
|
0
|
local *h_input = shift; |
123
|
0
|
|
|
|
|
0
|
my ( $key, $value, $rc); |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
$self->dprint("join to getrc"); |
126
|
0
|
0
|
|
|
|
0
|
$self->dprint("file ".$self->{'filename'}." doesn't exist"),return(-1) unless ( -e $self->{'filename'} ); |
127
|
0
|
0
|
0
|
|
|
0
|
$self->dprint("Can't read file ".$self->{'filename'}),return(-2) unless ( -r $self->{'filename'} || -R $self->{'filename'} ); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
### locking ? uff .. this a bit messy code |
130
|
0
|
0
|
|
|
|
0
|
if ( $self->{'lock'} ) { |
131
|
0
|
|
|
|
|
0
|
eval { |
132
|
0
|
|
|
0
|
|
0
|
local $SIG{ALRM} = sub { die "File lock timeouted\n" }; |
|
0
|
|
|
|
|
0
|
|
133
|
0
|
|
|
|
|
0
|
alarm($self->{'locktimeout'}); |
134
|
0
|
|
|
|
|
0
|
$self->dprint("openning file ".$self->{'filename'}); |
135
|
0
|
|
|
|
|
0
|
$rc = new IO::File $self->{'filename'}, O_RDONLY; |
136
|
0
|
0
|
|
|
|
0
|
croak "Can't open file ".$self->{'filename'}." : $!" unless ( defined $rc ); |
137
|
0
|
|
|
|
|
0
|
$self->dprint("locking file ".$self->{'filename'}); |
138
|
0
|
|
|
|
|
0
|
flock($rc,LOCK_EX); |
139
|
0
|
|
|
|
|
0
|
$self->dprint($self->{'filename'} . " locked"); |
140
|
0
|
|
|
|
|
0
|
alarm(0); |
141
|
|
|
|
|
|
|
}; |
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
0
|
if ($@) { |
144
|
0
|
0
|
|
|
|
0
|
$self->dprint("File lock timeouted\n") if $@ eq "File lock timeouted\n"; |
145
|
0
|
|
|
|
|
0
|
return(-3); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} else { |
149
|
0
|
|
|
|
|
0
|
$self->dprint("openning file ".$self->{'filename'}); |
150
|
0
|
|
|
|
|
0
|
$rc = new IO::File $self->{'filename'}, O_RDONLY; |
151
|
0
|
0
|
|
|
|
0
|
croak "Can't open file ".$self->{'filename'}." : $!" unless ( defined $rc ); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
0
|
my $separator = $self->{'ifs'}; |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
0
|
while (<$rc>) { |
157
|
0
|
|
|
|
|
0
|
chomp; |
158
|
|
|
|
|
|
|
#### Skip blank text entry fields and comment |
159
|
0
|
0
|
0
|
|
|
0
|
next if ( /^\s*#/ || /^\s*$/ || /^\s*\;/); |
|
|
|
0
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#### Allow for multiple line values |
162
|
0
|
0
|
|
|
|
0
|
if (s/\\$//) { |
163
|
0
|
|
|
|
|
0
|
$_ .= <$rc>; |
164
|
0
|
|
|
|
|
0
|
redo; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
0
|
($key,$value) = /\s*(.*?)${separator}(.*)/; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
### skip empty keys |
170
|
0
|
0
|
0
|
|
|
0
|
$self->dprint("skip line: $_"),next if ( !defined($value) || !$key ); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
#### Allow for multiple values of a single name |
173
|
0
|
0
|
0
|
|
|
0
|
if ($h_input{"$key"} && $self->{'multivalues'}) { |
174
|
0
|
|
|
|
|
0
|
$h_input{"$key"} .= ", " ; |
175
|
0
|
|
|
|
|
0
|
$h_input{"$key"} .= $value; |
176
|
|
|
|
|
|
|
} else { |
177
|
0
|
|
|
|
|
0
|
$h_input{"$key"} = $value; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
0
|
0
|
|
|
|
0
|
flock($rc,LOCK_UN),$self->dprint( $self->{'filename'} ." unlocked") if ( $self->{'lock'} ); |
181
|
0
|
|
|
|
|
0
|
$rc->close; |
182
|
0
|
0
|
|
|
|
0
|
croak "Can't close file ".$self->{'filename'} .": $1" if $?; |
183
|
0
|
|
|
|
|
0
|
$self->dprint( $self->{'filename'} ." closed"); |
184
|
0
|
|
|
|
|
0
|
return(0); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub updaterc ($\%){ |
188
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
189
|
1
|
|
|
|
|
3
|
local *h_input = shift; |
190
|
1
|
|
|
|
|
3
|
my ( $key, $value, $rc, %update_input); |
191
|
|
|
|
|
|
|
|
192
|
1
|
|
|
|
|
3
|
$self->dprint("join to updaterc"); |
193
|
1
|
50
|
|
|
|
39
|
$self->dprint("WARN: file ".$self->{'filename'}." doesn't exist") unless ( -e $self->{'filename'} ); |
194
|
1
|
50
|
33
|
|
|
22
|
$self->dprint("WARN: Can't read file ".$self->{'filename'}) unless ( -r $self->{'filename'} || -R $self->{'filename'} ); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
### locking ? uff .. this a bit messy code |
197
|
1
|
50
|
|
|
|
4
|
if ( $self->{'lock'} ) { |
198
|
1
|
|
|
|
|
7
|
eval { |
199
|
1
|
|
|
0
|
|
33
|
local $SIG{ALRM} = sub { die "File lock timeouted\n" }; |
|
0
|
|
|
|
|
0
|
|
200
|
1
|
|
|
|
|
13
|
alarm($self->{'locktimeout'}); |
201
|
1
|
|
|
|
|
6
|
$self->dprint("openning file ".$self->{'filename'}); |
202
|
1
|
|
|
|
|
12
|
$rc = new IO::File $self->{'filename'}, O_RDWR|O_CREAT; |
203
|
1
|
50
|
|
|
|
138
|
croak "Can't open file\n" unless ( defined $rc ); |
204
|
1
|
|
|
|
|
6
|
$self->dprint("locking file ".$self->{'filename'}); |
205
|
1
|
|
|
|
|
8
|
flock($rc,LOCK_EX); |
206
|
1
|
|
|
|
|
6
|
$self->dprint($self->{'filename'} . " locked"); |
207
|
1
|
|
|
|
|
16
|
alarm(0); |
208
|
|
|
|
|
|
|
}; |
209
|
|
|
|
|
|
|
|
210
|
1
|
50
|
|
|
|
4
|
if ($@) { |
211
|
0
|
0
|
|
|
|
0
|
return(-3),$self->dprint("File lock timeouted\n") if $@ eq "File lock timeouted\n"; |
212
|
0
|
0
|
|
|
|
0
|
return(-4),$self->dprint("Can't open file ".$self->{'filename'}) if $@ eq "Can't open file\n"; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
} else { |
217
|
0
|
|
|
|
|
0
|
$self->dprint("openning file ".$self->{'filename'}); |
218
|
0
|
|
|
|
|
0
|
$rc = new IO::File $self->{'filename'}, O_RDWR|O_CREAT; |
219
|
0
|
0
|
|
|
|
0
|
croak "Can't open file ".$self->{'filename'}." : $!" unless ( defined $rc ); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
1
|
|
|
|
|
3
|
my $separator = $self->{'ifs'}; |
223
|
|
|
|
|
|
|
|
224
|
1
|
|
|
|
|
27
|
while (<$rc>) { |
225
|
4
|
|
|
|
|
8
|
chomp; |
226
|
|
|
|
|
|
|
#### Skip blank text entry fields and comment |
227
|
4
|
50
|
33
|
|
|
41
|
next if ( /^\s*#/ || /^\s*$/ || /^\s*\;/); |
|
|
|
33
|
|
|
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
#### Allow for multiple line values |
230
|
4
|
50
|
|
|
|
17
|
if (s/\\$//) { |
231
|
0
|
|
|
|
|
0
|
$_ .= <$rc>; |
232
|
0
|
|
|
|
|
0
|
redo; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
4
|
|
|
|
|
61
|
($key,$value) = /\s*(.*?)${separator}(.*)/; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
### skip empty keys |
238
|
4
|
50
|
33
|
|
|
22
|
$self->dprint("skip line: $_"),next if ( !defined($value) || !$key ); |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
#### Allow for multiple values of a single name |
241
|
4
|
50
|
33
|
|
|
15
|
if ($update_input{"$key"} && $self->{'multivalues'}) { |
242
|
0
|
|
|
|
|
0
|
$update_input{"$key"} .= ", " ; |
243
|
0
|
|
|
|
|
0
|
$update_input{"$key"} .= $value; |
244
|
|
|
|
|
|
|
} else { |
245
|
4
|
|
|
|
|
28
|
$update_input{"$key"} = $value; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
1
|
|
|
|
|
7
|
while (($key,$value) = each %h_input) { |
250
|
2
|
|
|
|
|
10
|
$update_input{"$key"} = $value; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
1
|
|
|
|
|
2
|
$separator = $self->{'ofs'}; |
254
|
|
|
|
|
|
|
|
255
|
1
|
|
|
|
|
8
|
seek($rc,0,0); |
256
|
1
|
|
|
|
|
121
|
truncate($rc,0); |
257
|
|
|
|
|
|
|
|
258
|
1
|
|
|
|
|
46
|
while (($key,$value) = each %update_input) { |
259
|
5
|
|
|
|
|
21
|
print $rc "$key${separator}$value\n"; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
1
|
50
|
|
|
|
53
|
flock($rc,LOCK_UN),$self->dprint( $self->{'filename'} ." unlocked") if ( $self->{'lock'} ); |
264
|
1
|
|
|
|
|
11
|
$rc->close; |
265
|
1
|
50
|
|
|
|
20
|
croak "Can't close file ".$self->{'filename'} .": $1" if $?; |
266
|
1
|
|
|
|
|
7
|
$self->dprint( $self->{'filename'} ." closed"); |
267
|
1
|
|
|
|
|
7
|
return(0); |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub configure { |
271
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
272
|
0
|
|
|
|
|
0
|
my (%arg) = @_; |
273
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
0
|
foreach (keys %arg) { |
275
|
0
|
|
|
|
|
0
|
$self->{"$_"} = $arg{$_}; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
0
|
bless $self->{'find_path'}; |
279
|
0
|
|
|
|
|
0
|
return($self); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub dprint { |
283
|
14
|
|
|
14
|
0
|
25
|
my $self = shift; |
284
|
14
|
|
|
|
|
21
|
my $debug_output = shift; |
285
|
14
|
|
|
|
|
24
|
my $filename = $self->{'filename'}; |
286
|
14
|
50
|
|
|
|
60
|
return(0) unless $self->{'debug'}; |
287
|
0
|
|
|
|
|
0
|
print STDERR <
|
288
|
|
|
|
|
|
|
==> PID:$$\t$debug_output |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
EOM |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub AUTOLOAD { |
294
|
2
|
|
|
2
|
|
33
|
my $self = shift; |
295
|
2
|
|
|
|
|
5
|
my $value = shift; |
296
|
2
|
|
|
|
|
5
|
my ($name) = $AUTOLOAD; |
297
|
|
|
|
|
|
|
|
298
|
2
|
|
|
|
|
16
|
($name) = ( $name =~ /^.*::(.*)/); |
299
|
|
|
|
|
|
|
|
300
|
2
|
50
|
|
|
|
64
|
$self->{$name} = $value if ( defined $value ); |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
### find file location |
303
|
2
|
50
|
33
|
|
|
20
|
$self->_find_file if ( $value && ($name eq 'filename')); |
304
|
|
|
|
|
|
|
|
305
|
2
|
50
|
|
|
|
25
|
if ( ref($self->{$name}) =~ /ARRAY/ ) { |
|
|
50
|
|
|
|
|
|
306
|
0
|
|
|
|
|
0
|
return(@{$self->{$name}}); |
|
0
|
|
|
|
|
0
|
|
307
|
|
|
|
|
|
|
} elsif (isa($self->{$name}, 'ARRAY')) { |
308
|
0
|
0
|
|
|
|
0
|
if ( wantarray ) { |
309
|
0
|
|
|
|
|
0
|
return(@{$self->{$name}}); |
|
0
|
|
|
|
|
0
|
|
310
|
|
|
|
|
|
|
} else { |
311
|
0
|
|
|
|
|
0
|
return($self->{$name}); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
} else { |
314
|
2
|
|
|
|
|
8
|
return($self->{$name}); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub push { |
319
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
320
|
0
|
|
|
|
|
|
my $value = shift; |
321
|
|
|
|
|
|
|
|
322
|
0
|
0
|
|
|
|
|
return() unless (ref($self) !~ /ARRAY/ ); |
323
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
push @{$self},$value; |
|
0
|
|
|
|
|
|
|
325
|
0
|
|
|
|
|
|
return($self); |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
sub unshift { |
329
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
330
|
0
|
|
|
|
|
|
my $value = shift; |
331
|
|
|
|
|
|
|
|
332
|
0
|
0
|
|
|
|
|
return() unless (ref($self) !~ /ARRAY/ ); |
333
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
unshift @{$self},$value; |
|
0
|
|
|
|
|
|
|
335
|
0
|
|
|
|
|
|
return($self); |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub pop { |
339
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
340
|
|
|
|
|
|
|
|
341
|
0
|
0
|
|
|
|
|
return() unless (ref($self) !~ /ARRAY/ ); |
342
|
|
|
|
|
|
|
|
343
|
0
|
|
|
|
|
|
pop @{$self}; |
|
0
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub shift { |
347
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
348
|
|
|
|
|
|
|
|
349
|
0
|
0
|
|
|
|
|
return() unless (ref($self) !~ /ARRAY/ ); |
350
|
|
|
|
|
|
|
|
351
|
0
|
|
|
|
|
|
shift @{$self}; |
|
0
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
0
|
|
|
0
|
|
|
sub DESTROY {} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
1; |
358
|
|
|
|
|
|
|
__END__ |