in reply to Untainting 'bad' filenames

Well, I wouldn't match "anything" but if you know what the format is roughly going to look like, you could limit it to something like this:

if ($filename =~ m#^[\w.]$#) { print "Ready to process $1...\n"; } else { print "Skipping $1: bad characters detected\n"; ## Log to a file, email someone, raise a ruckus, etc. }