<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Pod::Html;
use strict;
use Exporter 'import';

our $VERSION = 1.35;
$VERSION = eval $VERSION;
our @EXPORT = qw(pod2html);

use Config;
use Cwd;
use File::Basename;
use File::Spec;
use Pod::Simple::Search;
use Pod::Simple::SimpleTree ();
use Pod::Html::Util qw(
    html_escape
    process_command_line
    trim_leading_whitespace
    unixify
    usage
    htmlify
    anchorify
    relativize_url
);
use locale; # make \w work right in non-ASCII lands

=head1 NAME

Pod::Html - module to convert pod files to HTML

=head1 SYNOPSIS

    use Pod::Html;
    pod2html([options]);

=head1 DESCRIPTION

Converts files from pod format (see L&lt;perlpod&gt;) to HTML format.  It
can automatically generate indexes and cross-references, and it keeps
a cache of things it knows how to cross-reference.

=head1 FUNCTIONS

=head2 pod2html

    pod2html("pod2html",
             "--podpath=lib:ext:pod:vms",
             "--podroot=/usr/src/perl",
             "--htmlroot=/perl/nmanual",
             "--recurse",
             "--infile=foo.pod",
             "--outfile=/perl/nmanual/foo.html");

pod2html takes the following arguments:

=over 4

=item backlink

    --backlink

Turns every C&lt;head1&gt; heading into a link back to the top of the page.
By default, no backlinks are generated.

=item cachedir

    --cachedir=name

Creates the directory cache in the given directory.

=item css

    --css=stylesheet

Specify the URL of a cascading style sheet.  Also disables all HTML/CSS
C&lt;style&gt; attributes that are output by default (to avoid conflicts).

=item flush

    --flush

Flushes the directory cache.

=item header

    --header
    --noheader

Creates header and footer blocks containing the text of the C&lt;NAME&gt;
section.  By default, no headers are generated.

=item help

    --help

Displays the usage message.

=item htmldir

    --htmldir=name

Sets the directory to which all cross references in the resulting
html file will be relative. Not passing this causes all links to be
absolute since this is the value that tells Pod::Html the root of the 
documentation tree.

Do not use this and --htmlroot in the same call to pod2html; they are
mutually exclusive.

=item htmlroot

    --htmlroot=name

Sets the base URL for the HTML files.  When cross-references are made,
the HTML root is prepended to the URL.

Do not use this if relative links are desired: use --htmldir instead.

Do not pass both this and --htmldir to pod2html; they are mutually
exclusive.

=item index

    --index
    --noindex

Generate an index at the top of the HTML file.  This is the default
behaviour.

=item infile

    --infile=name

Specify the pod file to convert.  Input is taken from STDIN if no
infile is specified.

=item outfile

    --outfile=name

Specify the HTML file to create.  Output goes to STDOUT if no outfile
is specified.

=item poderrors

    --poderrors
    --nopoderrors

Include a "POD ERRORS" section in the outfile if there were any POD 
errors in the infile. This section is included by default.

=item podpath

    --podpath=name:...:name

Specify which subdirectories of the podroot contain pod files whose
HTML converted forms can be linked to in cross references.

=item podroot

    --podroot=name

Specify the base directory for finding library pods. Default is the
current working directory.

=item quiet

    --quiet
    --noquiet

Don't display I&lt;mostly harmless&gt; warning messages.  These messages
will be displayed by default.  But this is not the same as C&lt;verbose&gt;
mode.

=item recurse

    --recurse
    --norecurse

Recurse into subdirectories specified in podpath (default behaviour).

=item title

    --title=title

Specify the title of the resulting HTML file.

=item verbose

    --verbose
    --noverbose

Display progress messages.  By default, they won't be displayed.

=back

=head2 Formerly Exported Auxiliary Functions

Prior to perl-5.36, the following three functions were exported by
F&lt;Pod::Html&gt;, either by default or on request:

=over 4

=item * C&lt;htmlify()&gt; (by default)

=item * C&lt;anchorify()&gt; (upon request)

=item * C&lt;relativize_url()&gt; (upon request)

=back

The definition and documentation of these functions have been moved to
F&lt;Pod::Html::Util&gt;, viewable via C&lt;perldoc Pod::Html::Util&gt;.

Beginning with perl-5.38 these functions must be explicitly imported from
F&lt;Pod::Html::Util&gt;.  Please modify your code as needed.

=head1 ENVIRONMENT

Uses C&lt;$Config{pod2html}&gt; to setup default options.

=head1 AUTHOR

Marc Green, E&lt;lt&gt;marcgreen@cpan.orgE&lt;gt&gt;. 

Original version by Tom Christiansen, E&lt;lt&gt;tchrist@perl.comE&lt;gt&gt;.

=head1 SEE ALSO

L&lt;perlpod&gt;

=head1 COPYRIGHT

This program is distributed under the Artistic License.

=cut

sub new {
    my $class = shift;
    return bless {}, $class;
}

sub pod2html {
    local(@ARGV) = @_;
    local $_;

    my $self = Pod::Html-&gt;new();
    $self-&gt;init_globals();

    my $opts = process_command_line;
    $self-&gt;process_options($opts);

    $self-&gt;refine_globals();

    # load or generate/cache %Pages
    unless ($self-&gt;get_cache()) {
        # generate %Pages
        #%Pages = $self-&gt;generate_cache(\%Pages);
        $self-&gt;generate_cache($self-&gt;{Pages});
    }
    my $input   = $self-&gt;identify_input();
    my $podtree = $self-&gt;parse_input_for_podtree($input);
    $self-&gt;set_Title_from_podtree($podtree);

    # set options for the HTML generator
    my $parser = Pod::Simple::XHTML::LocalPodLinks-&gt;new();
    $parser-&gt;codes_in_verbatim(0);
    $parser-&gt;anchor_items(1); # the old Pod::Html always did
    $parser-&gt;backlink($self-&gt;{Backlink}); # linkify =head1 directives
    $parser-&gt;force_title($self-&gt;{Title});
    $parser-&gt;htmldir($self-&gt;{Htmldir});
    $parser-&gt;htmlfileurl($self-&gt;{Htmlfileurl});
    $parser-&gt;htmlroot($self-&gt;{Htmlroot});
    $parser-&gt;index($self-&gt;{Doindex});
    $parser-&gt;output_string(\$self-&gt;{output}); # written to file later
    #$parser-&gt;pages(\%Pages);
    $parser-&gt;pages($self-&gt;{Pages});
    $parser-&gt;quiet($self-&gt;{Quiet});
    $parser-&gt;verbose($self-&gt;{Verbose});

    $parser = $self-&gt;refine_parser($parser);
    $self-&gt;feed_tree_to_parser($parser, $podtree);
    $self-&gt;write_file();
}

sub init_globals {
    my $self = shift;
    $self-&gt;{Cachedir} = ".";            # The directory to which directory caches
                                        #   will be written.

    $self-&gt;{Dircache} = "pod2htmd.tmp";

    $self-&gt;{Htmlroot} = "/";            # http-server base directory from which all
                                        #   relative paths in $podpath stem.
    $self-&gt;{Htmldir} = "";              # The directory to which the html pages
                                        #   will (eventually) be written.
    $self-&gt;{Htmlfile} = "";             # write to stdout by default
    $self-&gt;{Htmlfileurl} = "";          # The url that other files would use to
                                        # refer to this file.  This is only used
                                        # to make relative urls that point to
                                        # other files.

    $self-&gt;{Poderrors} = 1;
    $self-&gt;{Podfile} = "";              # read from stdin by default
    $self-&gt;{Podpath} = [];              # list of directories containing library pods.
    $self-&gt;{Podroot} = $self-&gt;{Curdir} = File::Spec-&gt;curdir;
                                        # filesystem base directory from which all
                                        #   relative paths in $podpath stem.
    $self-&gt;{Css} = '';                  # Cascading style sheet
    $self-&gt;{Recurse} = 1;               # recurse on subdirectories in $podpath.
    $self-&gt;{Quiet} = 0;                 # not quiet by default
    $self-&gt;{Verbose} = 0;               # not verbose by default
    $self-&gt;{Doindex} = 1;               # non-zero if we should generate an index
    $self-&gt;{Backlink} = 0;              # no backlinks added by default
    $self-&gt;{Header} = 0;                # produce block header/footer
    $self-&gt;{Title} = undef;             # title to give the pod(s)
    $self-&gt;{Saved_Cache_Key} = '';
    $self-&gt;{Pages} = {};
    return $self;
}

sub process_options {
    my ($self, $opts) = @_;

    $self-&gt;{Podpath}   = (defined $opts-&gt;{podpath})
                            ? [ split(":", $opts-&gt;{podpath}) ]
                            : [];

    $self-&gt;{Backlink}  =          $opts-&gt;{backlink}   if defined $opts-&gt;{backlink};
    $self-&gt;{Cachedir}  =  unixify($opts-&gt;{cachedir})  if defined $opts-&gt;{cachedir};
    $self-&gt;{Css}       =          $opts-&gt;{css}        if defined $opts-&gt;{css};
    $self-&gt;{Header}    =          $opts-&gt;{header}     if defined $opts-&gt;{header};
    $self-&gt;{Htmldir}   =  unixify($opts-&gt;{htmldir})   if defined $opts-&gt;{htmldir};
    $self-&gt;{Htmlroot}  =  unixify($opts-&gt;{htmlroot})  if defined $opts-&gt;{htmlroot};
    $self-&gt;{Doindex}   =          $opts-&gt;{index}      if defined $opts-&gt;{index};
    $self-&gt;{Podfile}   =  unixify($opts-&gt;{infile})    if defined $opts-&gt;{infile};
    $self-&gt;{Htmlfile}  =  unixify($opts-&gt;{outfile})   if defined $opts-&gt;{outfile};
    $self-&gt;{Poderrors} =          $opts-&gt;{poderrors}  if defined $opts-&gt;{poderrors};
    $self-&gt;{Podroot}   =  unixify($opts-&gt;{podroot})   if defined $opts-&gt;{podroot};
    $self-&gt;{Quiet}     =          $opts-&gt;{quiet}      if defined $opts-&gt;{quiet};
    $self-&gt;{Recurse}   =          $opts-&gt;{recurse}    if defined $opts-&gt;{recurse};
    $self-&gt;{Title}     =          $opts-&gt;{title}      if defined $opts-&gt;{title};
    $self-&gt;{Verbose}   =          $opts-&gt;{verbose}    if defined $opts-&gt;{verbose};

    warn "Flushing directory caches\n"
        if $opts-&gt;{verbose} &amp;&amp; defined $opts-&gt;{flush};
    $self-&gt;{Dircache} = "$self-&gt;{Cachedir}/pod2htmd.tmp";
    if (defined $opts-&gt;{flush}) {
        1 while unlink($self-&gt;{Dircache});
    }
    return $self;
}

sub refine_globals {
    my $self = shift;

    # prevent '//' in urls
    $self-&gt;{Htmlroot} = "" if $self-&gt;{Htmlroot} eq "/";
    $self-&gt;{Htmldir} =~ s#/\z##;

    if (  $self-&gt;{Htmlroot} eq ''
       &amp;&amp; defined( $self-&gt;{Htmldir} )
       &amp;&amp; $self-&gt;{Htmldir} ne ''
       &amp;&amp; substr( $self-&gt;{Htmlfile}, 0, length( $self-&gt;{Htmldir} ) ) eq $self-&gt;{Htmldir}
       ) {
        # Set the 'base' url for this file, so that we can use it
        # as the location from which to calculate relative links
        # to other files. If this is '', then absolute links will
        # be used throughout.
        #$self-&gt;{Htmlfileurl} = "$self-&gt;{Htmldir}/" . substr( $self-&gt;{Htmlfile}, length( $self-&gt;{Htmldir} ) + 1);
        # Is the above not just "$self-&gt;{Htmlfileurl} = $self-&gt;{Htmlfile}"?
        $self-&gt;{Htmlfileurl} = unixify($self-&gt;{Htmlfile});
    }
    return $self;
}

sub generate_cache {
    my $self = shift;
    my $pwd = getcwd();
    chdir($self-&gt;{Podroot}) ||
        die "$0: error changing to directory $self-&gt;{Podroot}: $!\n";

    # find all pod modules/pages in podpath, store in %Pages
    # - inc(0): do not prepend directories in @INC to search list;
    #     limit search to those in @{$self-&gt;{Podpath}}
    # - verbose: report (via 'warn') what search is doing
    # - laborious: to allow '.' in dirnames (e.g., /usr/share/perl/5.14.1)
    # - recurse: go into subdirectories
    # - survey: search for POD files in PodPath
    my ($name2path, $path2name) = 
        Pod::Simple::Search-&gt;new-&gt;inc(0)-&gt;verbose($self-&gt;{Verbose})-&gt;laborious(1)
        -&gt;recurse($self-&gt;{Recurse})-&gt;survey(@{$self-&gt;{Podpath}});
    # remove Podroot and extension from each file
    for my $k (keys %{$name2path}) {
        $self-&gt;{Pages}{$k} = _transform($self, $name2path-&gt;{$k});
    }

    chdir($pwd) || die "$0: error changing to directory $pwd: $!\n";

    # cache the directory list for later use
    warn "caching directories for later use\n" if $self-&gt;{Verbose};
    open my $cache, '&gt;', $self-&gt;{Dircache}
        or die "$0: error open $self-&gt;{Dircache} for writing: $!\n";

    print $cache join(":", @{$self-&gt;{Podpath}}) . "\n$self-&gt;{Podroot}\n";
    my $_updirs_only = ($self-&gt;{Podroot} =~ /\.\./) &amp;&amp; !($self-&gt;{Podroot} =~ /[^\.\\\/]/);
    foreach my $key (keys %{$self-&gt;{Pages}}) {
        if($_updirs_only) {
          my $_dirlevel = $self-&gt;{Podroot};
          while($_dirlevel =~ /\.\./) {
            $_dirlevel =~ s/\.\.//;
            # Assume $Pagesref-&gt;{$key} has '/' separators (html dir separators).
            $self-&gt;{Pages}-&gt;{$key} =~ s/^[\w\s\-\.]+\///;
          }
        }
        print $cache "$key $self-&gt;{Pages}-&gt;{$key}\n";
    }
    close $cache or die "error closing $self-&gt;{Dircache}: $!";
}

sub _transform {
    my ($self, $v) = @_;
    $v = $self-&gt;{Podroot} eq File::Spec-&gt;curdir
               ? File::Spec-&gt;abs2rel($v)
               : File::Spec-&gt;abs2rel($v,
                                     File::Spec-&gt;canonpath($self-&gt;{Podroot}));

    # Convert path to unix style path
    $v = unixify($v);

    my ($file, $dir) = fileparse($v, qr/\.[^.]*/); # strip .ext
    return $dir.$file;
}

sub get_cache {
    my $self = shift;

    # A first-level cache:
    # Don't bother reading the cache files if they still apply
    # and haven't changed since we last read them.

    my $this_cache_key = $self-&gt;cache_key();
    return 1 if $self-&gt;{Saved_Cache_Key} and $this_cache_key eq $self-&gt;{Saved_Cache_Key};
    $self-&gt;{Saved_Cache_Key} = $this_cache_key;

    # load the cache of %Pages if possible.  $tests will be
    # non-zero if successful.
    my $tests = 0;
    if (-f $self-&gt;{Dircache}) {
        warn "scanning for directory cache\n" if $self-&gt;{Verbose};
        $tests = $self-&gt;load_cache();
    }

    return $tests;
}

sub cache_key {
    my $self = shift;
    return join('!',
        $self-&gt;{Dircache},
        $self-&gt;{Recurse},
        @{$self-&gt;{Podpath}},
        $self-&gt;{Podroot},
        stat($self-&gt;{Dircache}),
    );
}

#
# load_cache - tries to find if the cache stored in $dircache is a valid
#  cache of %Pages.  if so, it loads them and returns a non-zero value.
#
sub load_cache {
    my $self = shift;
    my $tests = 0;
    local $_;

    warn "scanning for directory cache\n" if $self-&gt;{Verbose};
    open(my $cachefh, '&lt;', $self-&gt;{Dircache}) ||
        die "$0: error opening $self-&gt;{Dircache} for reading: $!\n";
    $/ = "\n";

    # is it the same podpath?
    $_ = &lt;$cachefh&gt;;
    chomp($_);
    $tests++ if (join(":", @{$self-&gt;{Podpath}}) eq $_);

    # is it the same podroot?
    $_ = &lt;$cachefh&gt;;
    chomp($_);
    $tests++ if ($self-&gt;{Podroot} eq $_);

    # load the cache if its good
    if ($tests != 2) {
        close($cachefh);
        return 0;
    }

    warn "loading directory cache\n" if $self-&gt;{Verbose};
    while (&lt;$cachefh&gt;) {
        /(.*?) (.*)$/;
        $self-&gt;{Pages}-&gt;{$1} = $2;
    }

    close($cachefh);
    return 1;
}

sub identify_input {
    my $self = shift;
    my $input;
    unless (@ARGV &amp;&amp; $ARGV[0]) {
        if ($self-&gt;{Podfile} and $self-&gt;{Podfile} ne '-') {
            $input = $self-&gt;{Podfile};
        } else {
            $input = '-'; # XXX: make a test case for this
        }
    } else {
        $self-&gt;{Podfile} = $ARGV[0];
        $input = *ARGV;
    }
    return $input;
}

sub parse_input_for_podtree {
    my ($self, $input) = @_;
    # set options for input parser
    my $input_parser = Pod::Simple::SimpleTree-&gt;new;
    # Normalize whitespace indenting
    $input_parser-&gt;strip_verbatim_indent(\&amp;trim_leading_whitespace);

    $input_parser-&gt;codes_in_verbatim(0);
    $input_parser-&gt;accept_targets(qw(html HTML));
    $input_parser-&gt;no_errata_section(!$self-&gt;{Poderrors}); # note the inverse

    warn "Converting input file $self-&gt;{Podfile}\n" if $self-&gt;{Verbose};
    my $podtree = $input_parser-&gt;parse_file($input)-&gt;root;
    return $podtree;
}

sub set_Title_from_podtree {
    my ($self, $podtree) = @_;
    unless(defined $self-&gt;{Title}) {
        if($podtree-&gt;[0] eq "Document" &amp;&amp; ref($podtree-&gt;[2]) eq "ARRAY" &amp;&amp;
            $podtree-&gt;[2]-&gt;[0] eq "head1" &amp;&amp; @{$podtree-&gt;[2]} == 3 &amp;&amp;
            ref($podtree-&gt;[2]-&gt;[2]) eq "" &amp;&amp; $podtree-&gt;[2]-&gt;[2] eq "NAME" &amp;&amp;
            ref($podtree-&gt;[3]) eq "ARRAY" &amp;&amp; $podtree-&gt;[3]-&gt;[0] eq "Para" &amp;&amp;
            @{$podtree-&gt;[3]} &gt;= 3 &amp;&amp;
            !(grep { ref($_) ne "" }
                @{$podtree-&gt;[3]}[2..$#{$podtree-&gt;[3]}]) &amp;&amp;
            (@$podtree == 4 ||
                (ref($podtree-&gt;[4]) eq "ARRAY" &amp;&amp;
                $podtree-&gt;[4]-&gt;[0] eq "head1"))) {
            $self-&gt;{Title} = join("", @{$podtree-&gt;[3]}[2..$#{$podtree-&gt;[3]}]);
        }
    }

    $self-&gt;{Title} //= "";
    $self-&gt;{Title} = html_escape($self-&gt;{Title});
    return $self;
}

sub refine_parser {
    my ($self, $parser) = @_;
    # We need to add this ourselves because we use our own header, not
    # ::XHTML's header. We need to set $parser-&gt;backlink to linkify
    # the =head1 directives
    my $bodyid = $self-&gt;{Backlink} ? ' id="_podtop_"' : '';

    my $csslink = '';
    my $tdstyle = ' style="background-color: #cccccc; color: #000"';

    if ($self-&gt;{Css}) {
        $csslink = qq(\n&lt;link rel="stylesheet" href="$self-&gt;{Css}" type="text/css" /&gt;);
        $csslink =~ s,\\,/,g;
        $csslink =~ s,(/.):,$1|,;
        $tdstyle= '';
    }

    # header/footer block
    my $block = $self-&gt;{Header} ? &lt;&lt;END_OF_BLOCK : '';
&lt;table border="0" width="100%" cellspacing="0" cellpadding="3"&gt;
&lt;tr&gt;&lt;td class="_podblock_"$tdstyle valign="middle"&gt;
&lt;big&gt;&lt;strong&gt;&lt;span class="_podblock_"&gt;&amp;nbsp;$self-&gt;{Title}&lt;/span&gt;&lt;/strong&gt;&lt;/big&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
END_OF_BLOCK

    # create own header/footer because of --header
    $parser-&gt;html_header(&lt;&lt;"HTMLHEAD");
&lt;?xml version="1.0" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;$self-&gt;{Title}&lt;/title&gt;$csslink
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;link rev="made" href="mailto:$Config{perladmin}" /&gt;
&lt;/head&gt;

&lt;body$bodyid&gt;
$block
HTMLHEAD

    $parser-&gt;html_footer(&lt;&lt;"HTMLFOOT");
$block
&lt;/body&gt;

&lt;/html&gt;
HTMLFOOT
    return $parser;
}

# This sub duplicates the guts of Pod::Simple::FromTree.  We could have
# used that module, except that it would have been a non-core dependency.
sub feed_tree_to_parser {
    my($self, $parser, $tree) = @_;
    if(ref($tree) eq "") {
        $parser-&gt;_handle_text($tree);
    } elsif(!($tree-&gt;[0] eq "X" &amp;&amp; $parser-&gt;nix_X_codes)) {
        $parser-&gt;_handle_element_start($tree-&gt;[0], $tree-&gt;[1]);
        $self-&gt;feed_tree_to_parser($parser, $_) foreach @{$tree}[2..$#$tree];
        $parser-&gt;_handle_element_end($tree-&gt;[0]);
    }
}

sub write_file {
    my $self = shift;
    $self-&gt;{Htmlfile} = "-" unless $self-&gt;{Htmlfile}; # stdout
    my $fhout;
    if($self-&gt;{Htmlfile} and $self-&gt;{Htmlfile} ne '-') {
        open $fhout, "&gt;", $self-&gt;{Htmlfile}
            or die "$0: cannot open $self-&gt;{Htmlfile} file for output: $!\n";
    } else {
        open $fhout, "&gt;-";
    }
    binmode $fhout, ":utf8";
    print $fhout $self-&gt;{output};
    close $fhout or die "Failed to close $self-&gt;{Htmlfile}: $!";
    chmod 0644, $self-&gt;{Htmlfile} unless $self-&gt;{Htmlfile} eq '-';
}

package Pod::Simple::XHTML::LocalPodLinks;
use strict;
use warnings;
use parent 'Pod::Simple::XHTML';

use File::Spec;
use File::Spec::Unix;

__PACKAGE__-&gt;_accessorize(
 'htmldir',
 'htmlfileurl',
 'htmlroot',
 'pages', # Page name =&gt; relative/path/to/page from root POD dir
 'quiet',
 'verbose',
);

sub resolve_pod_page_link {
    my ($self, $to, $section) = @_;

    return undef unless defined $to || defined $section;
    if (defined $section) {
        $section = '#' . $self-&gt;idify($section, 1);
        return $section unless defined $to;
    } else {
        $section = '';
    }

    my $path; # path to $to according to %Pages
    unless (exists $self-&gt;pages-&gt;{$to}) {
        # Try to find a POD that ends with $to and use that.
        # e.g., given L&lt;XHTML&gt;, if there is no $Podpath/XHTML in %Pages,
        # look for $Podpath/*/XHTML in %Pages, with * being any path,
        # as a substitute (e.g., $Podpath/Pod/Simple/XHTML)
        my @matches;
        foreach my $modname (keys %{$self-&gt;pages}) {
            push @matches, $modname if $modname =~ /::\Q$to\E\z/;
        }

        # make it look like a path instead of a namespace
        my $modloc = File::Spec-&gt;catfile(split(/::/, $to));

        if ($#matches == -1) {
            warn "Cannot find file \"$modloc.*\" directly under podpath, " . 
                 "cannot find suitable replacement: link remains unresolved.\n"
                 if $self-&gt;verbose;
            return '';
        } elsif ($#matches == 0) {
            $path = $self-&gt;pages-&gt;{$matches[0]};
            my $matchloc = File::Spec-&gt;catfile(split(/::/, $path));
            warn "Cannot find file \"$modloc.*\" directly under podpath, but ".
                 "I did find \"$matchloc.*\", so I'll assume that is what you ".
                 "meant to link to.\n"
                 if $self-&gt;verbose;
        } else {
            # Use [-1] so newer (higher numbered) perl PODs are used
            # XXX currently, @matches isn't sorted so this is not true
            $path = $self-&gt;pages-&gt;{$matches[-1]};
            my $matchloc = File::Spec-&gt;catfile(split(/::/, $path));
            warn "Cannot find file \"$modloc.*\" directly under podpath, but ".
                 "I did find \"$matchloc.*\" (among others), so I'll use that " .
                 "to resolve the link.\n" if $self-&gt;verbose;
        }
    } else {
        $path = $self-&gt;pages-&gt;{$to};
    }

    my $url = File::Spec::Unix-&gt;catfile(Pod::Html::Util::unixify($self-&gt;htmlroot),
                                        $path);

    if ($self-&gt;htmlfileurl ne '') {
        # then $self-&gt;htmlroot eq '' (by definition of htmlfileurl) so
        # $self-&gt;htmldir needs to be prepended to link to get the absolute path
        # that will be relativized
        $url = Pod::Html::Util::relativize_url(
            File::Spec::Unix-&gt;catdir(Pod::Html::Util::unixify($self-&gt;htmldir), $url),
            $self-&gt;htmlfileurl # already unixified
        );
    }

    return $url . ".html$section";
}

1;
</pre></body></html>