line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RecordStream::Executor::Getopt; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
62
|
use strict; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
238
|
|
4
|
11
|
|
|
11
|
|
48
|
use warnings; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
5102
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
44
|
|
|
44
|
0
|
67
|
my $class = shift; |
8
|
|
|
|
|
|
|
|
9
|
44
|
|
|
|
|
105
|
my $this = { |
10
|
|
|
|
|
|
|
'STRINGS' => [], |
11
|
|
|
|
|
|
|
'MODULES' => [], |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
44
|
|
|
|
|
84
|
bless $this, $class; |
15
|
|
|
|
|
|
|
|
16
|
44
|
|
|
|
|
76
|
return $this; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub arguments { |
20
|
44
|
|
|
44
|
0
|
58
|
my $this = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return ( |
23
|
1
|
|
|
1
|
|
760
|
'e=s' => sub { $this->push_string($_[1]); }, |
24
|
1
|
|
|
1
|
|
773
|
'E=s' => sub { $this->push_file($_[1]); }, |
25
|
3
|
|
|
3
|
|
2515
|
'M=s' => sub { $this->push_module($_[1], 1); }, |
26
|
2
|
|
|
2
|
|
1734
|
'm=s' => sub { $this->push_module($_[1], 0); }, |
27
|
44
|
|
|
|
|
409
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_strings { |
31
|
44
|
|
|
44
|
0
|
59
|
my $this = shift; |
32
|
44
|
|
|
|
|
51
|
my $args = shift; |
33
|
|
|
|
|
|
|
|
34
|
44
|
|
|
|
|
79
|
my $strings = $this->{'STRINGS'}; |
35
|
44
|
100
|
|
|
|
87
|
if(!@$strings) { |
36
|
42
|
50
|
|
|
|
116
|
if(!@$args) { |
37
|
0
|
|
|
|
|
0
|
die "Missing expression.\n"; |
38
|
|
|
|
|
|
|
} |
39
|
42
|
|
|
|
|
86
|
push @$strings, shift @$args; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Use map to avoid the undesired comma operator behaviour if we're ever |
43
|
|
|
|
|
|
|
# called in scalar context. return @{[ ..., ... ]} could also be used. |
44
|
44
|
|
|
|
|
84
|
return map { @$_ } $this->{'MODULES'}, $strings; |
|
88
|
|
|
|
|
210
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_string { |
48
|
44
|
|
|
44
|
0
|
65
|
my $this = shift; |
49
|
|
|
|
|
|
|
|
50
|
44
|
|
|
|
|
104
|
return join("", $this->get_strings(@_)); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub push_string { |
54
|
1
|
|
|
1
|
0
|
2
|
my $this = shift; |
55
|
1
|
|
|
|
|
1
|
my $string = shift; |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
2
|
push @{$this->{'STRINGS'}}, $string; |
|
1
|
|
|
|
|
3
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub push_file { |
61
|
1
|
|
|
1
|
0
|
2
|
my $this = shift; |
62
|
1
|
|
|
|
|
2
|
my $file = shift; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
3
|
my $string = $this->_slurp($file); |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
4
|
push @{$this->{'STRINGS'}}, $string; |
|
1
|
|
|
|
|
5
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _slurp { |
70
|
1
|
|
|
1
|
|
2
|
my $this = shift; |
71
|
1
|
|
|
|
|
2
|
my $file = shift; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
3
|
local $/; |
74
|
1
|
|
|
|
|
2
|
undef $/; |
75
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
47
|
open (my $fh, '<', $file) or die "Could not open code snippet file: $file: $!"; |
77
|
1
|
|
|
|
|
25
|
my $code = <$fh>; |
78
|
1
|
|
|
|
|
8
|
close $fh; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
11
|
return $code; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub push_module { |
84
|
5
|
|
|
5
|
0
|
11
|
my $this = shift; |
85
|
5
|
|
|
|
|
17
|
my ($module, $import) = split /=/, shift, 2; |
86
|
5
|
|
|
|
|
16
|
my $import_default = shift; |
87
|
5
|
|
|
|
|
9
|
my $statement; |
88
|
|
|
|
|
|
|
|
89
|
5
|
100
|
|
|
|
14
|
if (defined $import) { |
|
|
100
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# This syntax mimics the output of: |
91
|
|
|
|
|
|
|
# perl -MO=Deparse -MList::Util=sum,max -e1 |
92
|
3
|
|
|
|
|
17
|
$import =~ s/(?=[\\'])/\\/g; |
93
|
3
|
|
|
|
|
12
|
$statement = "use $module (split(/,/, '$import', 0));"; |
94
|
|
|
|
|
|
|
} elsif ($import_default) { |
95
|
1
|
|
|
|
|
4
|
$statement = "use $module;"; |
96
|
|
|
|
|
|
|
} else { |
97
|
1
|
|
|
|
|
61
|
$statement = "use $module ();"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
5
|
|
|
|
|
10
|
push @{$this->{'MODULES'}}, $statement; |
|
5
|
|
|
|
|
21
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |