Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Perl (http://www.programmingforums.org/forum21.html)
-   -   Shorterning this code: (http://www.programmingforums.org/showthread.php?t=10962)

kruptof Aug 6th, 2006 4:57 PM

Shorterning this code:
 
does anybody know hot to make this code shorter and more effecient:
:

$my_input = $ENV{QUERY_STRING};
$my_input=substr($my_input,9);
$my_input =~ s/%21/!/g;
$my_input =~ s/%22/"/g;
$my_input =~ s/%A3/£/g;
$my_input =~ s/%24/\$/g;

$my_input =~ s/%25/\%/g;
$my_input =~ s/%5E/^/g;
$my_input =~ s/%26/\&/g;
$my_input =~ s/%28/(/g;

$my_input =~ s/%29/)/g;
$my_input =~ s/%3D/=/g;
$my_input =~ s/%2B/+/g;
$my_input =~ s/%7B/{/g;

$my_input =~ s/%7D/}/g;
$my_input =~ s/%5B/[/g;
$my_input =~ s/%5D/]/g;
$my_input =~ s/%3A/:/g;

$my_input =~ s/%3B/;/g;
$my_input =~ s/%27/'/g;
$my_input =~ s/%23/\#/g;
$my_input =~ s/%7E/~/g;

$my_input =~ s/%7C/\|/g;
$my_input =~ s/%5C/\\/g;
$my_input =~ s/%3C/</g;
$my_input =~ s/%2C/,/g;


$my_input =~ s/%3E/>/g;
$my_input =~ s/%2F/\//g;
$my_input =~ s/%3F/?/g;
$my_input =~ s/%AC/¬/g;

$my_input =~ s/%60/`/g;
$my_input =~ s/\+/ /g;
$my_input =~ s/%0D%0A/<br>/g;


as you can see i am just trying decode the submission of a form. I thank you in advance for your replies.

andro Aug 6th, 2006 5:14 PM

This might work :o

:

my_input =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;

Not my code, found it on google :P

Dameon Aug 6th, 2006 5:31 PM

Link.

Infinite Recursion Aug 7th, 2006 12:20 AM

look into regular expressions


All times are GMT -5. The time now is 12:24 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC