in reply to use CGI vs use CGI qw(:standard)

Number 1 is a comment. The comment in the second one is wrong. It is a confusion between escape backslash in double quoted strings (and regex) and single backslash in single quoted strings.

As someone else mentioned, you should not be matching the backslash in the regex. Other platforms (or possibly some browsers on Windows) use other directory separators. Also, that regular expression allows some unsafe characters in the matched string.

# $file set to "C:\\images\\apple.gif" # $file set to 'C:\images\apple.gif';