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;
20 for my $config (@configs) {
21 my $info = transform_exceptions {
22 return $self->_gather_info($config);
24 $found{$config} = $info
27 return { perls => \%found };
32 my ($self, $config) = @_;
33 open my $fh, '<', $config
34 or fail "Unable to determine '$config': $!";
35 my $first_line = <$fh>;
37 unless defined $first_line and $first_line =~ m{^#.+configpm};
41 while (defined( my $line = <$fh> )) {
42 if ($line =~ m{tie\s+\%Config}) {
47 if ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*'(.*)',\s*$}i) {
50 elsif ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*undef,$}i) {
55 (defined $info{scriptdir} and $info{version})
56 ? (executable => join('/', $info{scriptdir}, 'perl' . $info{version}))
62 sub _find_possible_perl_configs {
64 (my $root = $self->root) =~ s{/$}{};
65 my $handle = handle_from_command sprintf
66 q{locate --regex '^%s/.*/Config.pm$'}, $root;
67 my @lines = <$handle>;