diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-12-18 17:56:45 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-12-19 13:55:20 +0100 |
commit | d71a9bd1fa374f9824b18f331ad39c48e25c15fd (patch) | |
tree | 81d69657421e7ebb367034de2c05bac3fe777db4 /pod/buildtoc | |
parent | 45ea9a6e0d15cab8408cc6c9c7292e8efd67db77 (diff) | |
download | perl-d71a9bd1fa374f9824b18f331ad39c48e25c15fd.tar.gz |
In buildtoc, eliminate @modpods by building %Found directly.
There's no need to use an intermediate array to store the results from
calling File::Find::find() as its only use is to build a hash of work to do,
by looping over it once.
Standardise on !! for the regex delimiter, and convert ^ and $ to \A and \z.
The temporary variable $pod can be eliminated, because it doesn't matter
whether $_ ends '.pod' or '.pm' in the code that follows.
Diffstat (limited to 'pod/buildtoc')
-rw-r--r-- | pod/buildtoc | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/pod/buildtoc b/pod/buildtoc index 5fcb938985..a8a05ff414 100644 --- a/pod/buildtoc +++ b/pod/buildtoc @@ -24,7 +24,7 @@ die "$0: Usage: $0 [--quiet]\n" my $state = get_pod_metadata(0, sub { warn @_ if @_ }, 'pod/perltoc.pod'); # Find all the modules -my @modpods; +my %done; find({no_chdir => 1, wanted => sub { if (/\.p(od|m)$/) { @@ -32,26 +32,19 @@ find({no_chdir => 1, return if m!(?:^|/)t/!; return if m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-) return if m!XS/(?:APItest|Typemap)!; - my $pod = $_; - return if $pod =~ s/pm$/pod/ && -e $pod; - push @modpods, $_; + return if s!pm\z!pod! && -e $_; + s!\.pod\z!!; + s!\Alib/!!; + s!/!::!g; + my_die("Duplicate files for $_, '$done{$_}' and '$File::Find::name'") + if exists $done{$_}; + + $done{$_} = $File::Find::name; + $Found{/\A[a-z]/ ? 'PRAGMA' : 'MODULE'}{$_} = $File::Find::name; } }}, 'lib'); -my_die "Can't find any pods!\n" unless @modpods; - -my %done; -for (@modpods) { - my $name = $_; - $name =~ s/\.p(m|od)$//; - $name =~ s-\Alib/--; - $name =~ s-/-::-g; - my_die("Duplicate files for $name, '$done{$name}' and '$_'") - if exists $done{$name}; - $done{$name} = $_; - - $Found{$name =~ /^[a-z]/ ? 'PRAGMA' : 'MODULE'}{$name} = $_; -} +my_die "Can't find any pods!\n" unless %done; # Accumulating everything into a lexical before writing to disk dates from the # time when this script also provided the functionality of regen/pod_rules.pl |