| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
7226
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Probe::Perl; |
|
4
|
|
|
|
|
|
|
{ |
|
5
|
|
|
|
|
|
|
$Probe::Perl::VERSION = '0.03'; |
|
6
|
|
|
|
|
|
|
} |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# TODO: cache values derived from launching an external perl process |
|
9
|
|
|
|
|
|
|
# TODO: docs refer to Config.pm and $self->{config} |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Config; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
50
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
2045
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
|
16
|
1
|
|
|
1
|
1
|
84
|
my $class = shift; |
|
17
|
1
|
|
50
|
|
|
9
|
my $data = shift || {}; |
|
18
|
1
|
|
|
|
|
5
|
return bless( $data, $class ); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub config { |
|
22
|
8
|
|
|
8
|
1
|
3272
|
my ($self, $key) = (shift, shift); |
|
23
|
8
|
100
|
|
|
|
21
|
if (@_) { |
|
24
|
2
|
50
|
|
|
|
6
|
unless (ref $self) { |
|
25
|
0
|
|
|
|
|
0
|
die "Can't set config values via $self->config(). Use $self->new() to create a local view"; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
2
|
|
|
|
|
6
|
$self->{$key} = shift; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
8
|
100
|
66
|
|
|
1347
|
return ref($self) && exists $self->{$key} ? $self->{$key} : $Config{$key}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub config_revert { |
|
33
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
34
|
1
|
50
|
|
|
|
4
|
die "Can't use config_revert() as a class method" unless ref($self); |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
8
|
delete $self->{$_} foreach @_; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub perl_version { |
|
40
|
2
|
|
|
2
|
1
|
3795
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
# Check the current perl interpreter |
|
42
|
|
|
|
|
|
|
# It's much more convenient to use $] here than $^V, but 'man |
|
43
|
|
|
|
|
|
|
# perlvar' says I'm not supposed to. Bloody tyrant. |
|
44
|
2
|
50
|
|
|
|
127
|
return $^V ? $self->perl_version_to_float(sprintf( "%vd", $^V )) : $]; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub perl_version_to_float { |
|
48
|
2
|
|
|
2
|
1
|
8
|
my ($self, $version) = @_; |
|
49
|
2
|
|
|
|
|
13
|
$version =~ s/\./../; # Double up the first dot so the output has one dot remaining |
|
50
|
2
|
|
|
|
|
20
|
$version =~ s/\.(\d+)/sprintf( '%03d', $1 )/eg; |
|
|
4
|
|
|
|
|
23
|
|
|
51
|
2
|
|
|
|
|
13
|
return $version; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _backticks { |
|
55
|
3
|
|
|
3
|
|
6
|
my $perl = shift; |
|
56
|
3
|
50
|
|
|
|
162
|
return unless -e $perl; |
|
57
|
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
7
|
my $fh; |
|
59
|
3
|
50
|
|
|
|
7
|
eval {open $fh, '-|', $perl, @_ or die $!}; |
|
|
3
|
|
|
|
|
7875
|
|
|
60
|
3
|
50
|
|
|
|
60
|
if (!$@) { |
|
61
|
3
|
100
|
|
|
|
6312
|
return <$fh> if wantarray; |
|
62
|
1
|
|
|
|
|
7
|
my $tmp = do {local $/=undef; <$fh>}; |
|
|
1
|
|
|
|
|
19
|
|
|
|
1
|
|
|
|
|
24448
|
|
|
63
|
1
|
|
|
|
|
179
|
return $tmp; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Quoting only happens on the path to perl - I control the rest of |
|
67
|
|
|
|
|
|
|
# the args and they don't need quoting. |
|
68
|
0
|
0
|
|
|
|
0
|
if ($^O eq 'MSWin32') { |
|
69
|
0
|
0
|
|
|
|
0
|
$perl = qq{"$perl"} if $perl =~ m{^[\w\\]+$}; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
0
|
|
|
|
|
0
|
$perl =~ s{([^\w\\])}{\\$1}g; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
return `$perl @_`; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub perl_is_same { |
|
78
|
1
|
|
|
1
|
1
|
84
|
my ($self, $perl) = @_; |
|
79
|
1
|
|
|
|
|
4
|
return _backticks($perl, qw(-MConfig=myconfig -e print -e myconfig)) eq Config->myconfig; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub find_perl_interpreter { |
|
83
|
4
|
|
|
4
|
1
|
31
|
my $self = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
4
|
50
|
|
|
|
114
|
return $^X if File::Spec->file_name_is_absolute($^X); |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
my $exe = $self->config('exe_ext'); |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
my $thisperl = $^X; |
|
90
|
0
|
0
|
|
|
|
0
|
if ($self->os_type eq 'VMS') { |
|
|
|
0
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# VMS might have a file version at the end |
|
92
|
0
|
0
|
|
|
|
0
|
$thisperl .= $exe unless $thisperl =~ m/$exe(;\d+)?$/i; |
|
93
|
|
|
|
|
|
|
} elsif (defined $exe) { |
|
94
|
0
|
0
|
|
|
|
0
|
$thisperl .= $exe unless $thisperl =~ m/$exe$/i; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
foreach my $perl ( $self->config('perlpath'), |
|
98
|
|
|
|
|
|
|
map( File::Spec->catfile($_, $thisperl), |
|
99
|
|
|
|
|
|
|
File::Spec->path() ) |
|
100
|
|
|
|
|
|
|
) { |
|
101
|
0
|
0
|
0
|
|
|
0
|
return $perl if -f $perl and $self->perl_is_same($perl); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
0
|
|
|
|
|
0
|
return; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Determine the default @INC for this Perl |
|
107
|
|
|
|
|
|
|
sub perl_inc { |
|
108
|
2
|
|
|
2
|
1
|
1189
|
my $self = shift; |
|
109
|
|
|
|
|
|
|
|
|
110
|
2
|
|
|
|
|
29
|
local $ENV{PERL5LIB}; # this is not considered part of the default. |
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
49
|
my $perl = $self->find_perl_interpreter(); |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
12
|
my @inc = _backticks($perl, qw(-l -e print -e for -e @INC)); |
|
115
|
2
|
|
|
|
|
20
|
chomp @inc; |
|
116
|
|
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
93
|
return @inc; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
{ |
|
122
|
|
|
|
|
|
|
my %OSTYPES = qw( |
|
123
|
|
|
|
|
|
|
aix Unix |
|
124
|
|
|
|
|
|
|
bsdos Unix |
|
125
|
|
|
|
|
|
|
dgux Unix |
|
126
|
|
|
|
|
|
|
dynixptx Unix |
|
127
|
|
|
|
|
|
|
freebsd Unix |
|
128
|
|
|
|
|
|
|
linux Unix |
|
129
|
|
|
|
|
|
|
hpux Unix |
|
130
|
|
|
|
|
|
|
irix Unix |
|
131
|
|
|
|
|
|
|
darwin Unix |
|
132
|
|
|
|
|
|
|
machten Unix |
|
133
|
|
|
|
|
|
|
next Unix |
|
134
|
|
|
|
|
|
|
openbsd Unix |
|
135
|
|
|
|
|
|
|
netbsd Unix |
|
136
|
|
|
|
|
|
|
dec_osf Unix |
|
137
|
|
|
|
|
|
|
svr4 Unix |
|
138
|
|
|
|
|
|
|
svr5 Unix |
|
139
|
|
|
|
|
|
|
sco_sv Unix |
|
140
|
|
|
|
|
|
|
unicos Unix |
|
141
|
|
|
|
|
|
|
unicosmk Unix |
|
142
|
|
|
|
|
|
|
solaris Unix |
|
143
|
|
|
|
|
|
|
sunos Unix |
|
144
|
|
|
|
|
|
|
cygwin Unix |
|
145
|
|
|
|
|
|
|
os2 Unix |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
dos Windows |
|
148
|
|
|
|
|
|
|
MSWin32 Windows |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
os390 EBCDIC |
|
151
|
|
|
|
|
|
|
os400 EBCDIC |
|
152
|
|
|
|
|
|
|
posix-bc EBCDIC |
|
153
|
|
|
|
|
|
|
vmesa EBCDIC |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
MacOS MacOS |
|
156
|
|
|
|
|
|
|
VMS VMS |
|
157
|
|
|
|
|
|
|
VOS VOS |
|
158
|
|
|
|
|
|
|
riscos RiscOS |
|
159
|
|
|
|
|
|
|
amigaos Amiga |
|
160
|
|
|
|
|
|
|
mpeix MPEiX |
|
161
|
|
|
|
|
|
|
); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub os_type { |
|
165
|
2
|
|
|
2
|
1
|
4
|
my $class = shift; |
|
166
|
2
|
|
33
|
|
|
12
|
return $OSTYPES{shift || $^O}; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
__END__ |