> -----Original Message-----
> From: Larry Steinberg [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 02, 2002 11:38 AM
> To: [EMAIL PROTECTED]
> Subject: grab another param from url
>
>
> Hi,
>
> I have a subroutine that grabs a parameter (city) from the url for use in
> the script (which produces a report with the value of that
> parameter). I now
> want to grab another parameter (state) and append it to the previous and
> have it also appear in the report. Preferably it would look like this:
> "Boston, MA" (without the quotes). Here's the code:
>
> sub parseUrl {
>
> $nPara = $tPara = "";
>
> ($nPara) = ( $line =~ /[\?&]N=([^&\s]+)/i );
> if ($nPara ne "") { $nPara = unpack_clean($nPara); }
>
> ($tPara) = ( $line =~ /[\?&]T=([^&\s]+)/i ); #gets city parameter
> (T=)
> if ($tPara ne "") { $tPara = unpack_clean($tPara); }
>
> if ($tPara ne "" && $err eq "cit") {
> # print "$tPara\n";
> if (exists $userCit{$tPara}) { $userCit{$tPara}++; }
> else { $userCit{$tPara}=1; $countCit++;}
> }
>
> How do I add the state parameter (S=)?
>
> Thanks!
>
> -Larry
How about somthing like this:
if ($ENV{'QUERY_STRING'}) {
my $temp = $ENV{'QUERY_STRING'};
my @pairs = split(/;/, $temp); # or whatever you have to split on
my %request;
foreach my $in(@pairs) {
my ($name,$value) = split(/=/,$in);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C",hex($1))/ge;
$request{$name} = $value;
}
# Do what you want with each one such as
# if (defined $request{'S'}) ...
}
}
So a URL could come in like so:
http://whatever.com/cgi-bin/script.cgi?a=whatever;b=somthing;c=this
Now you have values for a, b and c...
But I am sure there are a lot of better ways to do it.
CGI.pm can handle parsing of a URL and I believe would be safer
than this type of thing.
Barry
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]