
a.r.ferreira at gmail
Nov 14, 2006, 4:24 AM
Post #1 of 2
(157 views)
Permalink
|
|
Fwd: [perl #40866] Error on doc page? (File::Basename)
|
|
This report came via webmaster [at] perl It tells about a mistake at the docs of File::Basename (which can be see in 5.8.8 and the current sources of bleed). I think the attached patch makes it right, according to the other examples in the same doc page. diff -r -u perl-current/lib/File/Basename.pm perl-sources/lib/File/Basename.pm --- perl-current/lib/File/Basename.pm 2006-11-14 09:52:34.000000000 -0200 +++ perl-sources/lib/File/Basename.pm 2006-11-14 09:53:44.000000000 -0200 @@ -89,7 +89,7 @@ portion is removed and becomes the $suffix. # On Unix returns ("baz", "/foo/bar", ".txt") - fileparse("/foo/bar/baz", qr/\.[^.]*/); + fileparse("/foo/bar/baz.txt", qr/\.[^.]*/); If type is non-Unix (see C<fileparse_set_fstype()>) then the pattern matching for suffix removal is performed case-insensitively, since Adriano. On Mon Nov 13 15:34:11 2006, Thomas.O.Smailus [at] boeing wrote: > On the following page : > > http://perldoc.perl.org/File/Basename.html > <http://perldoc.perl.org/File/Basename.html> > > an example for the fileparse method, that uses the @suffixes option, > give sthe following example: > # On Unix returns ("baz", "/foo/bar", ".txt") > fileparse("/foo/bar/baz", qr/\.[^.]*/); > I'm not sure that this example is correct. Given the input to fileparse > which is the string "/foo/bar/baz", there is no way that asking it to > pull of suffixes that fit a . followed by a string of non-dot > characters, could in any form have it know that the suffix to the file > is ".txt", given that the example file name is just "baz" and not > "baz.txt". > > A corrected example would be: > > # On Unix returns ("baz", "/foo/bar.txt", ".txt") > fileparse("/foo/bar/baz", qr/\.[^.]*/); > or > # On Unix returns ("baz", "/foo/bar", "") > fileparse("/foo/bar/baz", qr/\.[^.]*/); > Or is it a built-in functionality of the fileparse method to assume a > .txt extension when non is present? > > > Thomas >
|