$bad_chars = qr{[!~?/@]}; # remove any potential bad characters $filename =~ s/$bad_chars//g;