X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFile%2FBasename.pm;h=887c7bae4a9fb13cbae95bf12172c86e72665661;hb=a8bf0cad84ba0e8477c2b4b1b02a57dbd376a155;hp=37faa6d4656f7dad7d248779efbda89f6b67fdc1;hpb=f1e2092112ce19460895ba277191c080271a49b1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/File/Basename.pm b/lib/File/Basename.pm index 37faa6d..887c7ba 100644 --- a/lib/File/Basename.pm +++ b/lib/File/Basename.pm @@ -12,14 +12,15 @@ dirname - extract just the directory from a path use File::Basename; - ($name,$path,$suffix) = fileparse($fullname,@suffixlist) + ($name,$path,$suffix) = fileparse($fullname,@suffixlist); + $name = fileparse($fullname,@suffixlist); fileparse_set_fstype($os_string); $basename = basename($fullname,@suffixlist); $dirname = dirname($fullname); ($name,$path,$suffix) = fileparse("lib/File/Basename.pm",qr{\.pm}); fileparse_set_fstype("VMS"); - $basename = basename("lib/File/Basename.pm",qr{\.pm}); + $basename = basename("lib/File/Basename.pm",".pm"); $dirname = dirname("lib/File/Basename.pm"); =head1 DESCRIPTION @@ -70,6 +71,8 @@ You are guaranteed that if you concatenate B, B, and B together in that order, the result will denote the same file as the input file specification. +In scalar context, fileparse() returns only the B part of the filename. + =back =head1 EXAMPLES @@ -130,7 +133,7 @@ directory name to be F<.>). # not be available. BEGIN { unless (eval { require re; }) - { eval ' sub re::import { $^H |= 0x00100000; } ' } + { eval ' sub re::import { $^H |= 0x00100000; } ' } # HINT_RE_TAINT import re 'taint'; } @@ -142,7 +145,7 @@ our(@ISA, @EXPORT, $VERSION, $Fileparse_fstype, $Fileparse_igncase); require Exporter; @ISA = qw(Exporter); @EXPORT = qw(fileparse fileparse_set_fstype basename dirname); -$VERSION = "2.71"; +$VERSION = "2.73"; # fileparse_set_fstype() - specify OS-based rules used in future @@ -167,6 +170,10 @@ sub fileparse_set_fstype { sub fileparse { my($fullname,@suffices) = @_; + unless (defined $fullname) { + require Carp; + Carp::croak("fileparse(): need a valid pathname"); + } my($fstype,$igncase) = ($Fileparse_fstype, $Fileparse_igncase); my($dirpath,$tail,$suffix,$basename); my($taint) = substr($fullname,0,0); # Is $fullname tainted? @@ -222,7 +229,7 @@ sub fileparse { $tail .= $taint if defined $tail; # avoid warning if $tail == undef wantarray ? ($basename .= $taint, $dirpath .= $taint, $tail) - : $basename .= $taint; + : ($basename .= $taint); }