in reply to Quick Regex question

wouldn't a split just do it???

@pathtofile = split(/\\/, $path); $file = pop(@pathtofile); $path here can be parsed from the form


Chady | http://chady.net/

Replies are listed 'Best First'.
Re: Re: Quick Regex question
by Corion (Patriarch) on Jan 14, 2001 at 01:46 UTC

    A split will only work, if the filename is delimited by a backslash ('\'). Under DOS/Windows, there is still the nasty and often overlooked possibility of having a filename like c:myfile.ext, which is a valid filename, meaning a file on the drive c: in the current directory for drive c:.

    So the split should at least be on [\\:], but if we want real portability, I second the use of File::Basename, which is in the standard Perl distribution.