You might find the
quotemeta function quite useful - it's exactly for this purposes.
Update: Alright - I shot before finish reading :/
About converting special characters: The CGI module gives you the function you need to do that.
About the date-check: m/\d{4}-\d{2}-\d{2}/ should do the trick - read perlre for why.
And finally, about mailing you: Sorry, I don't do that stuff. If one is searching for help in a special place s/he should also check back there for the answers - that's the way a community works, by sharing the thoughts. Especially on topics like this. It is easy that I might have missed the one or the other thing (like simply stated by this update ;) - others might add to it. That's not possible if I would have mailed you.... Think of it.
--
use signature;
signature(" So long\nAlfie");