http://www.perlmonks.org?node_id=110291


in reply to Paths in Perl

'course, there's a different issue if you're writing a CGI script which accepts a file upload.

Assuming you want to extract the filename from the pathname, I've been known to use something along the lines of this:

my ($filename) = ($pathname =~ m|[/\\:]([^/\\:]+)$|);
but if anyone has a better solution then I'd be interested to hear it.

andy.