From 348635e6c21a00044a27bb477ddaac6bb947baaa Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 6 Mar 2017 17:26:48 +0100 Subject: [PATCH 1/2] fix a pod link --- lib/Module/Reader.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Module/Reader.pm b/lib/Module/Reader.pm index 89fefb5..2ed0371 100644 --- a/lib/Module/Reader.pm +++ b/lib/Module/Reader.pm @@ -475,7 +475,7 @@ avoided unless you are introspecting the F<< C<@INC> hooks|perlfunc/require >>. The raw file handle to the file found. This will be either a file handle to a file found on disk, or something returned by an -F<< C<@INC> hook|perlfunc/require >>. The hook callback, if it exists, will not +L<< C<@INC> hook|perlfunc/require >>. The hook callback, if it exists, will not be taken into account by this method. =head3 read_callback From 7af06096e34e84c6e9561242583c22025c76c536 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 6 Jun 2017 18:47:38 +0200 Subject: [PATCH 2/2] include inc path for items in found if possible --- lib/Module/Reader.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Module/Reader.pm b/lib/Module/Reader.pm index 2ed0371..3253bef 100644 --- a/lib/Module/Reader.pm +++ b/lib/Module/Reader.pm @@ -115,8 +115,24 @@ sub _find { eval { if (my $found = $self->{found}) { if (defined( my $full = $found->{$file} )) { - my $open = length ref $full ? $self->_open_ref($full, $file) - : $self->_open_file($full, $file); + my $open; + if (length ref $full) { + $open = $self->_open_ref($full, $file); + } + else { + my ($fvol, $fpath, $ffn) = File::Spec->splitpath($full); + my ($vol, $path, $fn) = File::Spec->splitpath($file); + my @fpath = (File::Spec->splitdir($fpath), $ffn); + my @path = (File::Spec->splitdir($path), $fn); + 1 while @fpath && @path && pop @fpath eq pop @path; + my $inc; + if (!@path) { + my $maybe_inc = File::Spec->canonpath(File::Spec->catpath($vol, File::Spec->catdir(@fpath), '')); + ($inc) = grep { File::Spec->canonpath($_) eq $maybe_inc } @{$self->{inc}}; + } + + $open = $self->_open_file($full, $file, $inc); + } push @found, $open if $open; }