summaryrefslogtreecommitdiff
path: root/pod/buildtoc
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-11-10 15:41:47 +0100
committerNicholas Clark <nick@ccl4.org>2011-11-18 11:08:59 +0100
commit8c9aa8a047a5d0b94be0f7ef16c70c3dc5a7ecc7 (patch)
tree318bf60ada8c1f427b8ccbd84e7a3f4230125f56 /pod/buildtoc
parent3b0c5c72fe9178c3109891f3884c2417c94e5959 (diff)
downloadperl-8c9aa8a047a5d0b94be0f7ef16c70c3dc5a7ecc7.tar.gz
In buildtoc, refactor to de-duplicate code and variables.
Converting the globals %Pragmata and %Modules to keys in a single hash reduces the code size.
Diffstat (limited to 'pod/buildtoc')
-rw-r--r--pod/buildtoc35
1 files changed, 10 insertions, 25 deletions
diff --git a/pod/buildtoc b/pod/buildtoc
index 530dd2d71b..930cf70d85 100644
--- a/pod/buildtoc
+++ b/pod/buildtoc
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use vars qw(%Pragmata %Modules $Quiet);
+use vars qw(%Found $Quiet);
use File::Spec;
use File::Find;
use FindBin;
@@ -66,11 +66,7 @@ for (@modpods) {
$name =~ s-/-::-g;
next if $done{$name}++;
- if ($name =~ /^[a-z]/) {
- $Pragmata{$name} = $_;
- } else {
- $Modules{$name} = $_;
- }
+ $Found{$name =~ /^[a-z]/ ? 'PRAGMA' : 'MODULE'}{$name} = $_;
}
# Accumulating everything into a lexical before writing to disk dates from the
@@ -106,29 +102,18 @@ foreach (grep {defined $_ && @$_ == 3 && !$_->[0]{toc_omit}} @{$state->{master}}
podset(@$_);
}
-
-($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
+foreach my $type (qw(PRAGMA MODULE)) {
+ ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
- =head1 PRAGMA DOCUMENTATION
+ =head1 $type DOCUMENTATION
EOPOD2B
-foreach (sort keys %Pragmata) {
- podset($_, $Pragmata{$_});
-}
-
-($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
-
-
-
- =head1 MODULE DOCUMENTATION
-
-EOPOD2B
-
-foreach (sort keys %Modules) {
- podset($_, $Modules{$_});
+ foreach my $name (sort keys %{$Found{$type}}) {
+ podset($name, $Found{$type}{$name});
+ }
}
$_= <<"EOPOD2B";
@@ -258,8 +243,8 @@ sub generate_roffitall {
"\t\t\\",
map ({"\t\$maindir/$_.1\t\\"}sort keys %{$state->{aux}}),
"\t\t\\",
- map ({"\t\$libdir/$_.3\t\\"}sort keys %Pragmata),
+ map ({"\t\$libdir/$_.3\t\\"}sort keys %{$Found{PRAGMA}}),
"\t\t\\",
- map ({"\t\$libdir/$_.3\t\\"}sort keys %Modules),
+ map ({"\t\$libdir/$_.3\t\\"}sort keys %{$Found{MODULE}}),
)
}