summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWolfgang Laun <Wolfgang.Laun@alcatel.at>2001-12-12 11:52:21 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-12 13:45:21 +0000
commit5cf0a2f2007e5a1f536bf01bb814c9223a9c47b9 (patch)
treedc6d3d06cc5a568df30602417f083912d3082c31 /lib
parent8b24e160a9bb9b9b36e347d7f037058433ec43e6 (diff)
downloadperl-5cf0a2f2007e5a1f536bf01bb814c9223a9c47b9.tar.gz
Re: [PATCH] ID 20011206.007 File::Find:name set to empty string for "/"
Message-ID: <200112121052210220.001ACE6B@smtp.chello.at> p4raw-id: //depot/perl@13654
Diffstat (limited to 'lib')
-rw-r--r--lib/File/Find.pm21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/File/Find.pm b/lib/File/Find.pm
index 3fbeebc334..a0cfcb9932 100644
--- a/lib/File/Find.pm
+++ b/lib/File/Find.pm
@@ -150,7 +150,22 @@ C<$File::Find::dir> contains the current directory name, and C<$_> the
current filename within that directory. C<$File::Find::name> contains
the complete pathname to the file. You are chdir()'d to
C<$File::Find::dir> when the function is called, unless C<no_chdir>
-was specified. When C<follow> or C<follow_fast> are in effect, there is
+was specified. Note that when changing to directories is in effect
+the root directory (F</>) is a somewhat special case inasmuch as the
+concatenation of C<$File::Find::dir>, C<'/'> and C<$_> is not literally
+equal to C<$File::Find::name>. The table below summarizes all variants:
+
+ $File::Find::name $File::Find::dir $_
+ default / / .
+ no_chdir=>0 /etc / etc
+ /etc/x /etc x
+
+ no_chdir=>1 / / /
+ /etc / /etc
+ /etc/x /etc /etc/x
+
+
+When <follow> or <follow_fast> are in effect, there is
also a C<$File::Find::fullname>. The function may set
C<$File::Find::prune> to prune the tree unless C<bydepth> was
specified. Unless C<follow> or C<follow_fast> is specified, for
@@ -863,12 +878,12 @@ sub _find_dir($$$) {
}
else {
if ( substr($name,-2) eq '/.' ) {
- $name =~ s|/\.$||;
+ substr($name, length($name) == 2 ? -1 : -2) = '';
}
$dir = $p_dir;
$_ = ($no_chdir ? $dir_name : $dir_rel );
if ( substr($_,-2) eq '/.' ) {
- s|/\.$||;
+ substr($_, length($_) == 2 ? -1 : -2) = '';
}
}
# guarantee lstat at return to directory