hotshot has asked for the wisdom of the Perl Monks concerning the following question:

heloo guys!!

When sending information from web to the server, I have a javascript script to escape all illegal charecters (add % and stuff). is there a Perl script to unescape the information on the server side?

Hotshot

Replies are listed 'Best First'.
Re: Unescaping function
by fruiture (Curate) on Nov 17, 2002 at 14:35 UTC
Re: Unescaping function
by Wonko the sane (Curate) on Nov 17, 2002 at 16:18 UTC
    The URI::Escape module fruiture mentioned will do exactly what you are looking for.

    Here is essentially what that module would do, and how you can do the same without it.

    # To encode $string =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; # To decode $string =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;


    It is always nice to know how stuff works, but it is almost always
    better to still use the already thought through, (hopefully mostly debugged :-))
    solutions found in the modules on CPAN.

    Wonko

Re: Unescaping function
by Aristotle (Chancellor) on Nov 17, 2002 at 23:55 UTC