in reply to Re: File::Basename and File::MMagic for File Downloads from Website
in thread File::Basename and File::MMagic for File Downloads from Website

I am not getting the same results. On my Debian machine, I get the following output using some of the examples.
> perl -MFile::Basename -le "print basename 'foo/bar'" bar > perl -MFile::Basename -le "print basename 'Z:\my_files\docs\some_kin +d_of_manual.pdf'" Z:\my_files\docs\some_kind_of_manual.pdf > perl -MFile::Basename -le "print basename '/home/someguy/file.txt'" file.txt
  • Comment on Re^2: File::Basename and File::MMagic for File Downloads from Website
  • Download Code

Replies are listed 'Best First'.
Re^3: File::Basename and File::MMagic for File Downloads from Website
by ikegami (Patriarch) on Nov 21, 2008 at 02:05 UTC

    Sorry, it had been a while. It does behave in a system-specific fashion.

    Technically, what you ask is impossible. 'foo\bar' should return 'foo\bar' if a unix path and 'bar' if a Windows path, but you don't know what kind of path your client built. That means you might as well roll out code that does what you want it to do.

    my $basename = ( split /[:\/\\]/, $_ )[-1];