next if /^#/;
chomp;
$_ = $1 if /#.*pod\s*=\s*(\S+)/;
- my ($where, $what) = m|^(\S*)/(\S+)|;
- pod2man($where, $opts{man1dir}, $opts{man1ext}, $what);
+ my ($path, $leaf) = m|^(\S*/(\S+))|;
+ pod2man({$leaf, $path}, $opts{man1dir}, $opts{man1ext});
if ($has_man1dir) {
- if (my ($where2, $what2) = m|#.*link\s*=\s*(\S+)/(\S+)|) {
- my $old = "$opts{man1dir}/$what.$opts{man1ext}";
- my $new = "$opts{man1dir}/$what2.$opts{man1ext}";
+ if (my ($link) = m|#.*link\s*=\s*\S+/(\S+)|) {
+ my $old = "$opts{man1dir}/$leaf.$opts{man1ext}";
+ my $new = "$opts{man1dir}/$link.$opts{man1ext}";
unlink($new);
link($old, $new);
my $xold = $old;
}
sub pod2man {
- # @script is scripts names if we are installing manpages embedded
- # in scripts, () otherwise
- my($poddir, $mandir, $manext, @script) = @_;
+ my($what, $mandir, $manext) = @_;
if ($mandir eq ' ' or $mandir eq '') {
- if (@script) {
- warn "Skipping installation of $poddir/$_ man page.\n"
- foreach @script;
+ if (ref $what) {
+ warn "Skipping installation of $_ man page.\n"
+ foreach values %$what;
} else {
- warn "Skipping installation of $poddir man pages.\n";
+ warn "Skipping installation of $what man pages.\n"
}
return;
}
- print "installing from $poddir\n" if $opts{verbose};
+ if ($opts{verbose}) {
+ if (ref $what) {
+ print "installing $_\n"
+ foreach sort keys %$what;
+ } else {
+ print "installing from $what\n";
+ }
+ }
mkpath($mandir, $opts{verbose}, 0777) unless $opts{notify}; # In File::Path
- # Make a list of all the .pm and .pod files in the directory. We avoid
- # chdir because we are running with @INC = '../lib', and modules may wish
- # to dynamically require Carp::Heavy or other diagnostics warnings.
- # Hash the names of files we find, keys are names relative to perl build
- # dir ('.'), values are names relative to $poddir.
- my %modpods;
- if (@script) {
- %modpods = (map {$_, "$poddir/$_"} @script);
+
+ my $modpods;
+ if (ref $what) {
+ $modpods = $what;
}
else {
+ # Make a list of all the .pm and .pod files in the directory.
File::Find::find({no_chdir=>1,
wanted => sub {
# $_ is $File::Find::name when using no_chdir
if (-f $_ and /\.p(?:m|od)$/) {
my $fullname = $_;
- s!^\Q$poddir\E/!!;
+ s!^\Q$what\E/!!;
# perlfaq manpages are installed in section 1,
# so skip when searching files for section 3
return if m(perlfaq.?\.pod|perlglossary.pod);
- $modpods{$_} = $fullname;
+ $modpods->{$_} = $fullname;
}
}},
- $poddir);
+ $what);
}
my @to_process;
- foreach my $manpage (sort keys %modpods) {
- my $mod = $modpods{$manpage};
+ foreach my $manpage (sort keys %$modpods) {
+ my $mod = $modpods->{$manpage};
my $tmp;
# Skip .pm files that have corresponding .pod files, and Functions.pm.
next if (($tmp = $mod) =~ s/\.pm$/.pod/ && -f $tmp);