1 package System::Introspector::Probe::LibDirs::Perl;
6 use System::Introspector::Util qw(
13 default => sub { '/' },
18 return transform_exceptions {
19 my $pipe = $self->_open_locate_libdirs_pipe;
21 while (defined( my $line = <$pipe> )) {
23 $libdir{ $line } = transform_exceptions {
24 return { modules => $self->_gather_libdir_info($line) };
27 return { libdirs_perl => \%libdir };
31 sub _gather_libdir_info {
32 my ($self, $libdir) = @_;
34 my $pipe = $self->_open_locate_pm_pipe($libdir);
35 while (defined( my $line = <$pipe> )) {
37 my $metadata = Module::Metadata->new_from_file($line);
38 next unless $metadata->name;
39 my $sha = Digest::SHA->new(256);
41 my $version = $metadata->version;
42 push @{ $module{ $metadata->name } //= [] }, {
46 ? sprintf('%s', $version)
49 size => scalar(-s $line),
50 sha256_hex => $sha->hexdigest,
56 sub _open_locate_pm_pipe {
57 my ($self, $libdir) = @_;
58 return handle_from_command
59 sprintf q{find %s -name '*.pm'}, $libdir;
62 sub _open_locate_libdirs_pipe {
64 my $root = $self->root;
66 unless $root =~ m{/$};
67 return handle_from_command sprintf
68 q{locate --regex '^%s.*lib/perl5$'}, $root;
77 System::Introspector::Probe::LibDirs::Perl - Gather perl lib directory data
81 Finds locations that look like L<local::lib> or comparable Perl library
82 directories, and extracts module information from them.
88 This is the root path to be searched for library directories. Defaults
95 =item L<System::Introspector>
101 Copyright (c) 2012 the L<System::Introspector>
102 L<AUTHOR|System::Introspector/AUTHOR>,
103 L<CONTRIBUTORS|System::Introspector/CONTRIBUTORS> and
104 L<SPONSORS|System::Introspector/SPONSORS>.
108 This library is free software and may be distributed under the same terms