tommyw has asked for the wisdom of the Perl Monks concerning the following question:
dirname($_).'/'.basename($_) should yield the original value of $_, right? (This is under Solaris, or Linux, before comments are made about the direction of the slash).
Well, as I found whilst working on some web stuff, if $_ is a directory, and ends in a /, it doesn't.
perl -MFile::Basename -e 'foreach (@ARGV) { print "$_: ", dirname ($_) +, " : ", basename($_), "\n"}' /home/oed /home/oed/. /home/oed/ /home/oed: /home : oed /home/oed/.: /home/oed : . /home/oed/: /home :
So either it's a bug, or I've missed something in the documentation, and am being blatently dumb. Please tell me it's the latter ;-)
--
Tommy
Too stupid to live.
Too stubborn to die.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bug? in File::Basename
by sauoq (Abbot) on Aug 06, 2003 at 09:37 UTC | |
|
Re: Bug? in File::Basename
by adrianh (Chancellor) on Aug 06, 2003 at 09:37 UTC |