in reply to use File::Basename - need to specify OS?

No prob here if you use File::Basename (I don't know File::Base)

$ cat foo use File::Basename; $\="\n"; print $^O; $file = 'C:/Windows/images/hello.gif'; $filename = basename($file); print $filename; $ perl foo freebsd hello.gif
--
b10m

All code is usually tested, but rarely trusted.

Replies are listed 'Best First'.
Re: Re: use File::Basename - need to specify OS?
by kiat (Vicar) on Apr 21, 2004 at 07:00 UTC
    Thanks, b10m!

    I had a typo there (I've edited it). In my code, I've 'use File::Basename' and I need the line 'fileparse_set_fstype("MSDOS");' to get it to work.

      Tested it on FreeBSD, OpenBSD and Linux now, still no prob without setting the fileparse_set_fstype.

        FreeBSD OpenBSD Linux
      $^O freebsd openbsd linux
      File::Basename version 2.71 2.71 2.72
      Perl version 5.8.0 5.8.0 5.8.2
      --
      b10m

      All code is usually tested, but rarely trusted.
        Just a clarification...where is your file coming from? In my case, the file that's chosen for upload comes from a Windows machine. The script is run on a bsd-powered server.