1 package System::Introspector::Probe::Perls;
4 use System::Introspector::Util qw(
12 default => sub { '/' },
17 return transform_exceptions {
18 my @configs = $self->_find_possible_perl_configs;
21 for my $config (@configs) {
22 my $info = transform_exceptions {
23 return $self->_gather_info($config);
25 next if $info->{config}{sitelibexp}
26 and $seen{$info->{config}{sitelibexp}}++;
27 $found{$config} = $info
30 return { perls => \%found };
35 my ($self, $config) = @_;
36 open my $fh, '<', $config
37 or fail "Unable to determine '$config': $!";
38 my $first_line = <$fh>;
40 unless defined $first_line and $first_line =~ m{^#.+configpm};
44 while (defined( my $line = <$fh> )) {
45 if ($line =~ m{tie\s+\%Config}) {
50 if ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*'(.*)',\s*$}i) {
53 elsif ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*undef,$}i) {
58 (defined $info{scriptdir} and $info{version})
59 ? (executable => join('/', $info{scriptdir}, 'perl' . $info{version}))
65 sub _find_possible_perl_configs {
67 (my $root = $self->root) =~ s{/$}{};
68 my $handle = handle_from_command sprintf
69 q{locate --regex '^%s/.*/Config.pm$'}, $root;
70 my @lines = <$handle>;