CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Converting from hex string to ascii string - reading post data

 



saxophonemaster
New User

Aug 23, 2012, 10:59 AM

Post #1 of 2 (847 views)
Converting from hex string to ascii string - reading post data Can't Post

I'm having difficulty reading post data and converting it into the ascii representation of the string
The main issue is that in the following code the variable $value still has non alphanumerical characters such as %3D that is the equal sign. I'm not sure how to make these ascii characters.


Code
foreach $pair (@pairs) 
{
($name, $value) = split(/=/, $pair, 2);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
#print "<b>$name:</b> $value<br />";
$FORM{$name} = $value;
}



FishMonger
Veteran / Moderator

Aug 23, 2012, 12:12 PM

Post #2 of 2 (845 views)
Re: [saxophonemaster] Converting from hex string to ascii string - reading post data [In reply to] Can't Post

Don't manually parse the html form submission yourself. Use the CGI module.


Code
use strict; 
use warnings;
use CGI;

my $cgi = CGI->new;

# this line replaces your foreach loop and does it properly for both POST and GET submissions.
my %form = $cgi->Vars;


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives