strange behavior in File::Basename
From: perl coder (perlcdr_at_mail.rumania)
Date: 07/22/04
- Next message: Juha Laiho: "Re: DBI and DBI::Oracle packages configuration"
- Previous message: ulloa: "DBI and DBI::Oracle packages configuration"
- Next in thread: Slaven Rezic: "Re: strange behavior in File::Basename"
- Reply: Slaven Rezic: "Re: strange behavior in File::Basename"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Jul 2004 16:32:58 GMT
I'm using Perl 5.6.1 on Debian Linux 3.0
I noticed the module File::Basename doesn't behave like the shell
commands basename/dirname in a special case that's not described in the
module's documentation.
When a full directory path is given to the shell commands, the result is
consistent, no matter if the path ends with a trailing / or not:
$ dirname /usr/local/; basename /usr/local/
/usr
local
$ dirname /usr/local; basename /usr/local
/usr
local
When a full directory path is given to File::Basename, the result only
makes sense when the path does not contain a trailing / character:
$ perl -MFile::Basename -we '$p="/usr/local/"; print dirname($p),"\n",basename($p),"\n";'
/usr
$ perl -MFile::Basename -we '$p="/usr/local"; print dirname($p),"\n",basename($p),"\n";'
/usr
local
If the given path ends in /, then the final path element dissapears!
Unless I'm writing code for the great Houdini, I think this is a bug,
what do you think? :-)
-- No crazy stuff in my email. ;-)
- Next message: Juha Laiho: "Re: DBI and DBI::Oracle packages configuration"
- Previous message: ulloa: "DBI and DBI::Oracle packages configuration"
- Next in thread: Slaven Rezic: "Re: strange behavior in File::Basename"
- Reply: Slaven Rezic: "Re: strange behavior in File::Basename"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|