Thread ExtUtils::Installed findet nicht alle Module? (37 answers)
Opened by bianca at 2012-10-24 11:39

bianca
 2013-04-24 10:20
#167220 #167220
User since
2009-09-13
6977 Artikel
BenutzerIn

user image
Danke für den Anstoß, so habe ich es jetzt gelöst:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Find;

sub scan {
  my %found;
  for my $dir (@_) {
    my $topdir = $dir;
    find(
      sub {
        if (-f $File::Find::name && $File::Find::name =~ /\.pm$/ ) {
          my $fn = $File::Find::name;
          $fn =~ s/\Q$topdir//g;
          $fn =~ s/\//::/g;
          $fn =~ s/^:://g;
          $fn =~ s/\.pm//g;
          $found{$fn} = ($fn =~ tr/://) / 2;
        }
      },
      $dir
    );
  }
  %found;
}
my %found = scan(@INC); # erstmal alle Unterverzeichnisse einlesen
my @modules;
foreach my $name (sort {$found{$a} <=> $found{$b}} keys %found) {
  if ($found{$name}) {  # ab zweiter Hirarchie nicht mehr inventarisieren, z.B. nur Authen::SASL und nicht Authen::SASL::CRAM_MD5
    my @temp = split /::/,$name;
    my $flag = 0;
    for (my $z = 0; $z < scalar @temp - 1; $z ++) {
      if (defined $found{join('::',@temp[0..$z])}) {  # z.B. App::Packer::PAR hat nur die dritte Hirarchie
        $flag = 1;
        last;
      }
    }
    push @modules,$name if !$flag;
  }
  else { push @modules,$name; }
}
foreach (sort {lc $a cmp lc $b} @modules) {
  print "$_\n";
}

Das macht es für meine Zwecke etwas übersichtlicher und - soweit ich das sehe - stimmt es auch inhaltlich.
10 print "Hallo"
20 goto 10

View full thread ExtUtils::Installed findet nicht alle Module?