in reply to Scrubbing a local path in a file upload
I assume it's a typo, but you have a space betwixt =~, which assigns a large number to $file! It's kinda cool, actually; it evaluates to ~0, or 2**32-1 on my systems, probably yours too. (Unless you have use integer;.)
Typo aside, whenever you have slashes in a RE, it's best on the eyes to choose a different delimiter.
And instead of your first set of parens, you probably want (?:\\|/) or [\/], neither of which stores the match.
And, you were just matching (with 'm'), not substituting.
With all that, you could do the following, which strips everything up to and including the last slash
$file =~ s#^.*[\/]##
(Or use File::Basename per the other suggestion.)
Update: Slight revisions.
|
|---|