in reply to Bug? in File::Basename
irname($_).'/'.basename($_) should yield the original value of $_, right?
Nope :-)
It returns the dirname(), a slash, and the basename() appended together.
File::Basename just deals with strings. It doesn't do any file system checks. So when it sees:
/foo/bar/
It knows that bar is a directory because of the trailing slash. So the basename is the empty string.
With:
/foo/bar
there is no trailing slash so the basename is bar.
To quote from the docs:
The fileparse() routine divides a file specification into three parts: a leading path, a file name, and a suffix. The path contains everything up to and including the last directory separator in the input file specification. The remainder of the input file specification is then divided into name and suffix based on the optional patterns you specify in @suf- fixlist. 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. By proper use of @suffixlist, you can remove file types or versions for examination.
You are guaranteed that if you concatenate path, name, and suffix together in that order, the result will denote the same file as the input file specification.
|
|---|