Gossamer Forum
Home : General : Perl Programming :

Wanna Help about CGI

Quote Reply
Wanna Help about CGI
Script code:

if ($ENV{'REQUEST_METHOD'} eq 'GET')
{$buffer=$ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$str{$name} = $value;}}

There is my problem, i want using =~tr function change + to %2B ,
but i can't do it, under is my trying ,


if ($str{'name'}=~tr/+/%2B/) {print "Hello $str{'name'}\n\n";exit;}

when i input C++ inside the HTML form text field then run it....

the result is give me Hello C%%

anotherway i try to using \ front of the %2B ,that means is

if ($str{'name'}=~tr/+/\%2B/) {print "Hello $str{'name'}\n\n";exit;}

oh, it still print the result is Hello C%%

Somebody can teach me using which function to modify this script can be
change + to %2B of the $str{$name} on my case???

Thank
Subject Author Views Date
Thread Wanna Help about CGI PDK1999 3315 May 21, 2003, 7:34 AM
Post Re: [PDK1999] Wanna Help about CGI
Paul 3175 May 21, 2003, 7:56 AM
Post Re: [PDK1999] Wanna Help about CGI
Andy 3181 May 21, 2003, 8:40 AM