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: Intermediate:
Havoc from Spaces!

 



andy7t
User

Aug 28, 2003, 6:39 AM

Post #1 of 3 (871 views)
Havoc from Spaces! Can't Post

Hi,

read(STDIN,$indata,$ENV{'CONTENT_LENGTH'});
@indata = split(/&/,$indata);
foreach $i (0..$#indata)
{
$indata[$i] =~ s/\+/ /g;
($key,$val) = split(/=/,$indata[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$indata{$key} .= "\0" if (defined($indata{$key}));
$indata{$key} .= $val;
}


This reads data inputted from another page.

But what i need to be able to do is get rid of the last character of EACH $indata IF it is a space.

e.g "This " goes to "This"

Thanks


Paul
Enthusiast

Aug 28, 2003, 7:23 AM

Post #2 of 3 (867 views)
Re: [andy7t] Havoc from Spaces! [In reply to] Can't Post

You need to remove that code from your script and use CGI.pm which is more secure and better written.


KevinR
Veteran


Aug 28, 2003, 12:00 PM

Post #3 of 3 (863 views)
Re: [andy7t] Havoc from Spaces! [In reply to] Can't Post

read(STDIN,$indata,$ENV{'CONTENT_LENGTH'});
@indata = split(/&/,$indata);
foreach $i (0..$#indata)
{
$indata[$i] =~ s/\+/ /g;
($key,$val) = split(/=/,$indata[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$indata{$key} .= "\0" if (defined($indata{$key}));
$indata{$key} .= $val;
chop($indata{$key}) if ($indata{$key} =~ /\s$/);
}
-------------------------------------------------

 
 


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

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