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


in reply to unpacking - html re-encoding?

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");

Replies are listed 'Best First'.
Re: Re: unpacking - html re-encoding?
by iakobski (Pilgrim) on Jul 18, 2001 at 11:26 UTC
    quotemeta is close but not a perfect fit. It will escape (with a backslash) any non-alphanumeric which includes ALL punctuation and even spaces.

    In most dialects of SQL, quotes are escaped by doubling them:

    he said, "I'LL be back"
    Would need to become:
    'he said, "I''LL be back"'
    Using the example given by the questioner. There's no need to escape other punctuation or spaces. And I said most, because the quoting given by DBI::quote() will match that required by the database transparently.

    Update OK, alfie so you updated your reply while I was writing that. And ++ for the bit about asking for an e-mail.

    -- iakobski