summaryrefslogtreecommitdiff
path: root/lib/File/Basename.pm
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2005-07-07 07:16:01 -0700
committerSteve Hay <SteveHay@planit.com>2005-07-08 08:43:07 +0000
commit08bc7695a2f08a85d93cf60f86512524ac215df2 (patch)
treefa4764b87721ec9b5458c60fd4db451208b2db5a /lib/File/Basename.pm
parent809e8e66a971d59a948ca995e08b228927d82c66 (diff)
downloadperl-08bc7695a2f08a85d93cf60f86512524ac215df2.tar.gz
Re: [perl #36477] File::Basename basename() bug
Message-ID: <20050707211601.GA3769@windhund.schwern.org> p4raw-id: //depot/perl@25096
Diffstat (limited to 'lib/File/Basename.pm')
-rw-r--r--lib/File/Basename.pm10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/File/Basename.pm b/lib/File/Basename.pm
index 345edcfe3e..cc6ba5853a 100644
--- a/lib/File/Basename.pm
+++ b/lib/File/Basename.pm
@@ -206,9 +206,13 @@ quoted.
sub basename {
- my($name) = shift;
- _strip_trailing_sep($name);
- (fileparse($name, map("\Q$_\E",@_)))[0];
+ my($path) = shift;
+
+ _strip_trailing_sep($path);
+ my($basename, $dirname) = fileparse( $path, map("\Q$_\E",@_) );
+ $basename = $dirname unless length $basename;
+
+ return $basename;
}