in reply to Re: Quick Regex Needed
in thread Quick Regex Needed

Right, but it's important to know what sort of system you happen to be using, so that you invoke the fileparse_set_fstype() function when necessary:
$ uname -s Darwin $ echo '\one\two\three\four' \one\two\three\four $ echo '\one\two\three\four' | perl -MFile::Basename -lne 'print basename($_)' \one\two\three\four $ echo '\one\two\three\four' | perl -MFile::Basename -lne 'BEGIN{fileparse_set_fstype("DOS")} prin +t basename($_)' four
The above would work out the same way if the result of "uname -s" had been linux or unix.

Replies are listed 'Best First'.
Re^3: Quick Regex Needed
by ikegami (Patriarch) on Oct 22, 2008 at 02:20 UTC

    Only if you assume he wasn't dealing with a path in the first place.

    I assumed the OP was dealing with paths. If he's not, I believe he's better off not using File::Basename at all rather than your workaround.