| 1 | package System::Introspector::Probe::Perls; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use System::Introspector::Util qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | transform_exceptions | ||||||||||||||||||||||||||||||||||||||||||
| 6 | handle_from_command | ||||||||||||||||||||||||||||||||||||||||||
| 7 | fail | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | has root => ( | ||||||||||||||||||||||||||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | default => sub { '/' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub gather { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gather: called CC=1 SCAR=0.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | return transform_exceptions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my @configs = $self->_find_possible_perl_configs; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my %found; | |||||||||||||||||||||||||||||||||||||||||
| 20 | my %seen; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | for my $config (@configs) { | |||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | my $info = transform_exceptions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | return $self->_gather_info($config); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 25 | next if $info | ||||||||||||||||||||||||||||||||||||||||||
| 26 | and $info->{config}{sitelibexp} | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | and $seen{$info->{config}{sitelibexp}}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$info and $info->{"config"}{"sitelibexp"} and $seen{$info->{"config"}{"sitelibexp"}}++
$info and $info->{"config"}{"sitelibexp"}
MC/DC0%0/3
$info and $info->{"config"}{"sitelibexp"} and $seen{$info->{"config"}{"sitelibexp"}}++
$info
$info->{"config"}{"sitelibexp"}
$seen{$info->{"config"}{"sitelibexp"}}++
Truth table25%1/4
A and B and C
A= $infoB= $info->{"config"}{"sitelibexp"}C= $seen{$info->{"config"}{"sitelibexp"}}++
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | $found{$config} = $info | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | if defined $info; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | return { perls => \%found }; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | sub _gather_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gather_info: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my ($self, $config) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | open my $fh, '<', $config | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | or fail "Unable to determine '$config': $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my $first_line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||
| 40 | return undef | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | unless defined $first_line and $first_line =~ m{^#.+configpm}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $first_line and $first_line =~ /^#.+configpm/
MC/DC0%0/2
defined $first_line and $first_line =~ /^#.+configpm/
defined $first_line
$first_line =~ /^#.+configpm/
Truth table33%1/3
A and B
A= defined $first_lineB= $first_line =~ /^#.+configpm/
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | my %info; | |||||||||||||||||||||||||||||||||||||||||
| 43 | my $is_info; | ||||||||||||||||||||||||||||||||||||||||||
| 44 | LINE: | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | while (defined( my $line = <$fh> )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 202 | ▶ | if ($line =~ m{tie\s+\%Config}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | $is_info++; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | next LINE; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 200 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 200 | ▶ | if ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*'(.*)',\s*$}i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 42 | $info{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | elsif ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*undef,$}i) { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | $info{$1} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | (defined $info{scriptdir} and $info{version}) | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | ? (executable => join('/', $info{scriptdir}, 'perl' . $info{version})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $info{"scriptdir"} and $info{"version"}
MC/DC0%0/2
defined $info{"scriptdir"} and $info{"version"}
defined $info{"scriptdir"}
$info{"version"}
Truth table33%1/3
A and B
A= defined $info{"scriptdir"}B= $info{"version"}
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | : (), | ||||||||||||||||||||||||||||||||||||||||||
| 62 | config => \%info, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub _find_possible_perl_configs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_possible_perl_configs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | (my $root = $self->root) =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $handle = handle_from_command sprintf | |||||||||||||||||||||||||||||||||||||||||
| 70 | q{locate --regex '^%s/.*/Config.pm$'}, $root; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my @lines = <$handle>; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | chomp @lines; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||||||||||||||||