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);
26 and $info->{config}{sitelibexp}
27 and $seen{$info->{config}{sitelibexp}}++;
28 $found{$config} = $info
31 return { perls => \%found };
36 my ($self, $config) = @_;
37 open my $fh, '<', $config
38 or fail "Unable to determine '$config': $!";
39 my $first_line = <$fh>;
41 unless defined $first_line and $first_line =~ m{^#.+configpm};
45 while (defined( my $line = <$fh> )) {
46 if ($line =~ m{tie\s+\%Config}) {
51 if ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*'(.*)',\s*$}i) {
54 elsif ($line =~ m{^\s*([a-z0-9_]+)\s*=>\s*undef,$}i) {
59 (defined $info{scriptdir} and $info{version})
60 ? (executable => join('/', $info{scriptdir}, 'perl' . $info{version}))
66 sub _find_possible_perl_configs {
68 (my $root = $self->root) =~ s{/$}{};
69 my $handle = handle_from_command sprintf
70 q{locate --regex '^%s/.*/Config.pm$'}, $root;
71 my @lines = <$handle>;
82 System::Introspector::Probe::Perls - Locate perl installations
86 Tries to locate perl installations on the system and collects
87 information about them.
93 =item L<System::Introspector>
99 Copyright (c) 2012 the L<System::Introspector>
100 L<AUTHOR|System::Introspector/AUTHOR>,
101 L<CONTRIBUTORS|System::Introspector/CONTRIBUTORS> and
102 L<SPONSORS|System::Introspector/SPONSORS>.
106 This library is free software and may be distributed under the same terms