in reply to Re: parse file name
in thread parse file name

The scenario is, I need to get the filename and file path no matter it is in windows or unix type.

it can be either of the below
my $long_file = '/abc/xyz/abc.txt';
my $long_file = '\abc\xyz\abc.txt';

In this case File::Basename and File::Spec wont return the directory part if the file name is windows format and i am running the script from unix.

Any Solution for this?
Thanks, Tom

Replies are listed 'Best First'.
Re^3: parse file name
by afoken (Chancellor) on Sep 26, 2009 at 07:55 UTC

    Replace all backslashes in $long_file with forward slashes before working with $long_file. Using the tr/// operator should be the most efficient implementation.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)