Perl bug File::Basename and Perl's nature

In article 7fe97cc4.0401242131.22acf485@posting.google.com,

···

Xah Lee xah@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.

Hi!

  • Walter Roberson:

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

This is not correct. There actually is a convention:

versioning
versioning.~1~
versioning.~2~
versioning.~3~
versioning.~4~
versioning.~5~
versioning.~6~
versioning.~7~
versioning.~8~
versioning.~9~

The above was generated by ‘le’ but many Editors use it. Works fine
with XEmacs on Windows as well :->

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.

Which becomes obvious when mounting the CDROM as plain ISO 9660 when
it actually uses Rockridge extensions or a Joliet filesystem.

Josef ‘Jupp’ SCHUGT

···


http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby-FAQ
http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Germany 2004: To boldly spy where no GESTAPO / STASI has spied before