Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 6th, 2006, 3:57 PM   #1
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3 kruptof is on a distinguished road
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.
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Aug 6th, 2006, 4:14 PM   #2
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 294
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
This might work :o

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

Not my code, found it on google
andro is offline   Reply With Quote
Old Aug 6th, 2006, 4:31 PM   #3
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Link.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Aug 6th, 2006, 11:20 PM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
look into regular expressions
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Little help whoawhoayoyo Assembly 8 Apr 18th, 2006 7:10 PM
Functions returing a pointer using new Jessehk C++ 29 Dec 21st, 2005 2:52 AM
How to post a question nnxion C++ 10 Jun 3rd, 2005 11:53 AM
How to post a question nnxion C++ 0 Jun 3rd, 2005 8:55 AM
How to post a question nnxion C 0 Jun 3rd, 2005 8:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:37 AM.

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