It is good to learn but parsing input yourself is a bad idea for lots of reasons, like 
all of the issues mentioned below.
& or ;
Post or get
Special charcter encoding
How input comes in -> buffer, $ENV var, etcc

When you can have all that just by doing

use CGI qw/:standard/;

Plus you get lots of other goodies you can use if you need/want

I did that use statement with Benchmark for kicks and to load it, and run about six of 
it's routines ( plus you'll have all input ready to use )

Took 0.00005 wallclock seconds 


Just fyi

DMuey


> -----Original Message-----
> From: R. Joseph Newton [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 04, 2003 3:09 PM
> To: Luinrandir Hernsen
> Cc: Dan Muey; [EMAIL PROTECTED]
> Subject: Re: please please comfirm (was Parsing variables)
> 
> 
> Luinrandir Hernsen wrote:
> 
> > Thank you for your help but I want to learn this too....
> >
> > Here is the code from the HTML GET
> 
> First, I am sort of mystified as to why you want to use the 
> GET method.  This method is designed specifically for cases 
> where you want to download the specified file.  It is as 
> likely as anything to just confuse the server.  The method 
> for posting information is POST.
> 
> 
> > <a 
> > href="move.pl?direction=NW&amp;cx=5&amp;cy=10&amp;player=Lou;">North
> > West</a>
> >
> > And here I think is the CGI code
> >
> > $input=$ENV{QUERY_STRING};
> >     @pairs = split(/&/, $input);
> 
> Good so far, but there are issues with portability.  There 
> apparently are some protocols that use a semi-colon rather 
> than ampersand for joining request elements.  Therefpore, you 
> might want to use /[&;]/ as you split parameter
> 
> >
> >          foreach $pair (@pairs)
> >          {
> >          ($name, $value)=split(/=/,$pair);
> 
> Problem:  you still have spaces showing as plus signs, and 
> any control characters encoded as twodigit hex preceded by a 
> percent sign: ['%2C' for ','].  It will take a coule more 
> lines to restore these:
>    $value =~( tr/+/ /);     # restores spaces
>    $value =~ s/%([a-fA-F0-9][a-fA-f0-9])/pack("C", hex($1))/eg;
>                                        # replaces hex escapes 
> with ascii equivalents
> 
> 
> >          $form{$name}= $value;
> >          }
> >     $direction=$form(direction);
> >     $cx=$form(cx);
> >     $cy=$form(cy);
> >     $player=$form(player);
> >
> > This should break it down so
> >     $direction=NW
> >     $cx=5
> >     $cy=10
> >     $player=Lou
> 
> Joseph
> 
> 

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

Reply via email to