line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Env::ShellWords; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
163420
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
366
|
use Text::ParseWords qw( shellwords ); |
|
1
|
|
|
|
|
1653
|
|
|
1
|
|
|
|
|
94
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Environment variables for arguments as array |
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
11
|
use constant _NAME => 0; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
88
|
|
12
|
1
|
|
|
1
|
|
9
|
use constant _SPLIT => 1; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
61
|
|
13
|
1
|
|
|
1
|
|
8
|
use constant _JOIN => 2; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1242
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _join |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
join ' ', map { |
18
|
13
|
|
|
13
|
|
26
|
my $value = $_; |
|
78
|
|
|
|
|
100
|
|
19
|
78
|
100
|
|
|
|
111
|
$value = '' unless defined $value; |
20
|
78
|
|
|
|
|
148
|
$value =~ s/(\s)/\\$1/g; |
21
|
78
|
100
|
|
|
|
195
|
$value eq '' ? "''" : $value; |
22
|
|
|
|
|
|
|
} @_; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub TIEARRAY |
26
|
|
|
|
|
|
|
{ |
27
|
13
|
|
|
13
|
|
17366
|
my($class, $name, $read, $write) = @_; |
28
|
13
|
|
100
|
|
|
110
|
bless [$name, $read || \&shellwords, $write || \&_join ], $class; |
|
|
|
100
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub FETCH |
32
|
|
|
|
|
|
|
{ |
33
|
15
|
|
|
15
|
|
1854
|
my($self, $key) = @_; |
34
|
15
|
|
|
|
|
38
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
35
|
15
|
|
|
|
|
756
|
$list[$key]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _render |
39
|
|
|
|
|
|
|
{ |
40
|
15
|
|
|
15
|
|
508
|
my $self = shift; |
41
|
15
|
|
|
|
|
32
|
$ENV{$self->[_NAME]} = $self->[_JOIN]->(@_); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub STORE |
45
|
|
|
|
|
|
|
{ |
46
|
3
|
|
|
3
|
|
290
|
my($self, $key, $value) = @_; |
47
|
3
|
|
|
|
|
11
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
48
|
3
|
|
|
|
|
410
|
$list[$key] = $value; |
49
|
3
|
|
|
|
|
9
|
_render($self, @list); |
50
|
3
|
|
|
|
|
9
|
$value; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub FETCHSIZE |
54
|
|
|
|
|
|
|
{ |
55
|
8
|
|
|
8
|
|
868
|
my($self) = @_; |
56
|
8
|
|
|
|
|
24
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
57
|
8
|
|
|
|
|
1008
|
$#list + 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub STORESIZE |
61
|
|
|
|
|
|
|
{ |
62
|
1
|
|
|
1
|
|
8
|
my($self, $count) = @_; |
63
|
1
|
|
|
|
|
5
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
64
|
1
|
|
|
|
|
141
|
$#list = $count - 1; |
65
|
1
|
|
|
|
|
5
|
_render($self, @list); |
66
|
1
|
|
|
|
|
6
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub CLEAR |
70
|
|
|
|
|
|
|
{ |
71
|
1
|
|
|
1
|
|
6
|
my($self) = @_; |
72
|
1
|
|
|
|
|
3
|
_render($self); |
73
|
1
|
|
|
|
|
3
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub PUSH |
77
|
|
|
|
|
|
|
{ |
78
|
2
|
|
|
2
|
|
416
|
my($self, @values) = @_; |
79
|
2
|
|
|
|
|
27
|
_render($self, $self->[_SPLIT]->($ENV{$self->[_NAME]}), @values); |
80
|
2
|
|
|
|
|
13
|
return; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub POP |
84
|
|
|
|
|
|
|
{ |
85
|
2
|
|
|
2
|
|
7
|
my($self) = @_; |
86
|
2
|
|
|
|
|
8
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
87
|
2
|
|
|
|
|
278
|
my $value = pop @list; |
88
|
2
|
|
|
|
|
5
|
_render($self, @list); |
89
|
2
|
|
|
|
|
11
|
return $value; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub SHIFT |
93
|
|
|
|
|
|
|
{ |
94
|
2
|
|
|
2
|
|
7
|
my($self) = @_; |
95
|
2
|
|
|
|
|
7
|
my($value, @list) = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
96
|
2
|
|
|
|
|
262
|
_render($self, @list); |
97
|
2
|
|
|
|
|
10
|
return $value; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub UNSHIFT |
101
|
|
|
|
|
|
|
{ |
102
|
3
|
|
|
3
|
|
15
|
my($self, @values) = @_; |
103
|
3
|
|
|
|
|
13
|
_render($self, @values, $self->[_SPLIT]->($ENV{$self->[_NAME]})); |
104
|
3
|
|
|
|
|
15
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub SPLICE |
108
|
|
|
|
|
|
|
{ |
109
|
0
|
|
|
0
|
|
0
|
my($self, $offset, $length, @values) = @_; |
110
|
0
|
|
|
|
|
0
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
111
|
0
|
|
|
|
|
0
|
my @ret = splice @list, $offset, $length, @values; |
112
|
0
|
|
|
|
|
0
|
_render($self, @list); |
113
|
0
|
|
|
|
|
0
|
@ret; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub DELETE |
117
|
|
|
|
|
|
|
{ |
118
|
1
|
|
|
1
|
|
10
|
my($self, $key) = @_; |
119
|
1
|
|
|
|
|
4
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
120
|
1
|
|
|
|
|
143
|
my $value = delete $list[$key]; |
121
|
1
|
|
|
|
|
5
|
_render($self, @list); |
122
|
1
|
|
|
|
|
8
|
return $value; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub EXISTS |
126
|
|
|
|
|
|
|
{ |
127
|
2
|
|
|
2
|
|
353
|
my($self, $key) = @_; |
128
|
2
|
|
|
|
|
6
|
my @list = $self->[_SPLIT]->($ENV{$self->[_NAME]}); |
129
|
2
|
|
|
|
|
301
|
return exists $list[$key]; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
0
|
|
|
sub EXTEND {} # do nothing! |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub import |
135
|
|
|
|
|
|
|
{ |
136
|
2
|
|
|
2
|
|
25
|
my $caller = caller; |
137
|
2
|
|
|
|
|
8
|
my(undef, @vars) = @_; |
138
|
2
|
|
|
|
|
1036
|
foreach my $var (@vars) |
139
|
|
|
|
|
|
|
{ |
140
|
1
|
50
|
|
|
|
11
|
if($var =~ s/^\@//) |
141
|
|
|
|
|
|
|
{ |
142
|
1
|
|
|
1
|
|
11
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
140
|
|
143
|
1
|
|
|
|
|
12
|
tie my @list, __PACKAGE__, $var; |
144
|
1
|
|
|
|
|
3
|
*{"${caller}::${var}"} = \@list; |
|
1
|
|
|
|
|
2233
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
else |
147
|
|
|
|
|
|
|
{ |
148
|
0
|
|
|
|
|
|
require Carp; |
149
|
0
|
|
|
|
|
|
Carp::croak("Env::ShellWords does not work with $var"); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
__END__ |