perl bug File::Basename and Perl's nature

Walter Roberson roberson at ibd.nrc-cnrc.gc.ca
Sun Jan 25 01:18:50 EST 2004


In article <7fe97cc4.0401242131.22acf485 at posting.google.com>,
Xah Lee <xah at xahlee.org> wrote:
:the crime in question this time is the module File::Basename.

:1. create a directory containing a file of this name: "cdrom.html".
:2. "use File::Basename;", with the line:
:   ($name,$path,$suffix) = fileparse($File::Find::name, ('.html',
:'.m'));
:3. Notice that your cdrom.html will be parsed into "cdr" with suffix
:"om.html".

:Now, if you peruse the "documentation" of "perldoc File::Basename",
:you'll see that it shouldn't be so.

The program did what it was documented to do.

: The
: remainder of the input file specification is then
: divided into name and suffix based on the
: optional patterns you specify in
: @suffixlist. Each element of this list can be a
: qr-quoted pattern (or a string which is
: interpreted as a regular expression), and is
: matched against the end of name. If this
: succeeds, the matching portion of name is removed
: and prepended to suffix.

So the suffixlist is a set of *patterns*. And '.m' is a *pattern*
that means "any character followed by the character 'm'.

Probably what you wanted to code was:

($name,$path,$suffix) = fileparse($File::Find::name, ('\.html', '\.m'));


: Here is a better documentation for the fileparse subroutine.

Your "better" documentation does not describe how the directory string
is derived.


:Not every morons in this world is using unix with its morinic
:convention of appending things to file names as a versioning system,

There is no widespread unix convention of appending things to
file names as a versioning system. The convention of appending
a version was probably most common in VMS, which used filenames
of the form  $device:[directory.directory]filename.filetype;version
such as $DISK0:[ROBERSON.SOURCE]HELLO.C;17

The use of extension information was present in CPM (1973) -- borrowed
from VMS. CPM begat QDOS which begat DOS which begat Windows.

The VMS structure of filename.filetype;version was adopted as the
ISO9660 filesystem for CDROMs. You don't *see* that because there
are common extensions to provide filename mapping, but every
ISO standard CDROM filesystem uses that structure underneath.
Including the common Rockridge extensions, and including when you
put a Joilet filesystem on a CDROM.
-- 
   Come to think of it, there are already a million monkeys on a million
   typewriters, and Usenet is NOTHING like Shakespeare.  -- Blair Houghton.



More information about the Python-list mailing list