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


in reply to removing special characters

Don't think of it as removing the special characters. Think of it as keeping the safe/useful characters. It is a subtle thing but you'll be well served in the future if you keep that attitude. You can spend all day adding more and more special characters or you can just removed everything that you aren't sure is valid. You'll always miss things but it is easier to allow one extra thing you missed than clean up your database or hacked server when you allowed something you shouldn't have.

As an example, to keep only upper case letters and numbers, you might do: $scalar =~ s/[^A-Z0-9]+//g; which removes from the string every character that isn't in the A-Z or 0-9 range.

--
$you = new YOU;
honk() if $you->love(perl)