1 package System::Introspector::LibDirs::Perl;
8 default => sub { '/' },
13 my $pipe = $self->_open_locate_libdirs_pipe;
15 while (defined( my $line = <$pipe> )) {
17 $libdir{ $line } = $self->_gather_libdir_info($line);
22 sub _gather_libdir_info {
23 my ($self, $libdir) = @_;
25 my $pipe = $self->_open_locate_pm_pipe($libdir);
26 while (defined( my $line = <$pipe> )) {
28 my $metadata = Module::Metadata->new_from_file($line);
29 next unless $metadata->name;
30 my $sha = Digest::SHA->new(256);
32 push @{ $module{ $metadata->name } //= [] }, {
34 version => $metadata->version,
35 size => scalar(-s $line),
36 sha256_hex => $sha->hexdigest,
42 sub _open_locate_pm_pipe {
43 my ($self, $libdir) = @_;
45 q{find %s -name '*.pm'},
47 open my $pipe, '-|', $command
48 or die "Unable to open pipe to '$command': $!\n";
52 sub _open_locate_libdirs_pipe {
54 my $root = $self->root;
56 unless $root =~ m{/$};
58 q{locate --regex '^%s.*lib/perl5$'},
60 open my $pipe, '-|', $command
61 or die "Unable to open pipe to '$command': $!\n";