From: "Larry Steinberg" <[EMAIL PROTECTED]>
> 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 = "";

I don't see any "my" there ...
        my ($nPara, $tPara) = ("","");

You don't wanna overwrite someone else's variables do you?

> 
>     ($nPara) = ( $line =~ /[\?&]N=([^&\s]+)/i );

Where exactly did you get the $line from?
This is supposeed to be a function, it should get the data as it's 
parameters, not reading some global variables!


>     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++;}
>     }

Yeah, fiddling with several global variables, not returning anything 
.... why exactly did you put the code into "sub whatever {...}"?


> How do I add the state parameter (S=)?

Step 1: get rid of the code
Step 2: get a decent programming introduction book
Step 3: read it

And when you come back do not forget that all Perl scripts should 
start with
        #!/usr/bin/perl -w
        use strict;
and the CGIs with
        #!/usr/bin/perl -w
        use strict;
        use CGI;


Jenda

P.S.: Sorry if I sound harsh, but it's better to get the basics 
right. You might be able to finish what are you doing right now even 
without them, but everything is harder that way.

P.P.S.: I probably should not press [Send] now, but I will anyway. 
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to