You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Daniel B. Hemmerich" <da...@webclients.net> on 2006/08/31 17:17:53 UTC

Receiving user input

Anyone have a code snippet of a routine that will parse both POST and GET
user input and place it into a hash?

 

Thanks!

 


Re: Receiving user input

Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Aug 31, 2006, at 11:39 AM, Michael Peters wrote:
> or just CGI. It's come standard with perl for ages now.

yes, but libapreq is way faster

Re: Receiving user input

Posted by Michael Peters <mp...@plusthree.com>.

Jonathan Vanasco wrote:
> 
> On Aug 31, 2006, at 11:17 AM, Daniel B. Hemmerich wrote:
> 
>> Anyone have a code snippet of a routine that will parse both POST and
>> GET user input and place it into a hash?
> libapreq -> param ?

or just CGI. It's come standard with perl for ages now.

my $cgi = CGI->new();
my $vars = $cgi->Vars();

-- 
Michael Peters
Developer
Plus Three, LP


Re: Receiving user input

Posted by Jonathan Vanasco <jo...@2xlp.com>.
On Aug 31, 2006, at 11:17 AM, Daniel B. Hemmerich wrote:

> Anyone have a code snippet of a routine that will parse both POST  
> and GET user input and place it into a hash?
libapreq -> param ?


Re: Receiving user input

Posted by Kjetil Kjernsmo <kj...@opera.com>.
On Thursday 31 August 2006 17:17, Daniel B. Hemmerich wrote:
> Anyone have a code snippet of a routine that will parse both POST and
> GET user input and place it into a hash?

Using libapreq, how about something like 

  my %FORM = ();
 
  my $req = Apache2::Request->new($r);

  foreach my $name ($req->param) {
    next if ($FORM{$name});
    my @values = $req->param($name);
    $FORM{$name} = \@values;
  }

Completely untested, taken from thin air, but you might like to give it 
a try.

-- 
Kjetil Kjernsmo
Information Systems Developer
Opera Software ASA

Re: Receiving user input

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2006-08-31 at 13:58 -0700, Jay Scherrer wrote:
> So if we are not to forget 
> our predecessors and learn from others examples, then I would submit the 
> ReadParse routine from "cgi-lib.pl" as good place to start. 

No, that's just the point.  It's not good enough, and should not be
used.  There's no reason to use cgi-lib.pl for any new code in this day
and age.

- Perrin


Re: Receiving user input

Posted by Jay Scherrer <ja...@scherrer.com>.
Perrin Harkins wrote:
> On Thu, 2006-08-31 at 09:23 -0700, Jay Scherrer wrote:
>   
>> I have used "cgi-lib.pl" from <http://cgi-lib.berkeley.edu> for awhile now.
>>     
>
> Please don't use that.  It is outdated and has problems with security
> and with standards compliance.  Use CGI.pm instead.  It's a painless
> transition.  See the CGI.pm docs for information on how to port your
> code.
>
> - Perrin
>
>
>   
Yes, of course CGI.pm is the most up to date module. The question was 
"Anyone have a code snippet of a routine that will parse both POST and 
GET user input and place it into a hash?".  So if we are not to forget 
our predecessors and learn from others examples, then I would submit the 
ReadParse routine from "cgi-lib.pl" as good place to start. 

# ReadParse
# Reads in GET or POST data, converts it to unescaped text, and puts
# key/value pairs in %in, using "\0" to separate multiple selections

Jay Scherrer





Re: Receiving user input

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2006-08-31 at 09:23 -0700, Jay Scherrer wrote:
> I have used "cgi-lib.pl" from <http://cgi-lib.berkeley.edu> for awhile now.

Please don't use that.  It is outdated and has problems with security
and with standards compliance.  Use CGI.pm instead.  It's a painless
transition.  See the CGI.pm docs for information on how to port your
code.

- Perrin


Re: Receiving user input

Posted by Frank Wiles <fr...@wiles.org>.
On Thu, 31 Aug 2006 17:48:42 +0100
"Hendrik Van Belleghem" <he...@gmail.com> wrote:

> AARGH! Get out the axes and pointy sticks! cgi-lib.pl hasn't been
> updated since 1998 (quick delta: 8 years). CGI.pm has stepped in as
> the de-facto module for CGI stuff.. CGI.pm DOES do mod_perl as well
> (although I personally have no experience with this)
> 
> Stick to CGI.pm or even better, Apache::Request :)
> 
> my 2 cents

   Agreed.  CGI.pm if you are comfortable with it and/or need to be
   able to work in a CGI and/or mod_perl environment.  Or use libapreq. 

   Personally, I've only used libapreq for the last several years. 

   Anything else would be uncivilized. :) 

 ---------------------------------
   Frank Wiles <fr...@wiles.org>
   http://www.wiles.org
 ---------------------------------


Re: Receiving user input

Posted by Hendrik Van Belleghem <he...@gmail.com>.
AARGH! Get out the axes and pointy sticks! cgi-lib.pl hasn't been
updated since 1998 (quick delta: 8 years). CGI.pm has stepped in as
the de-facto module for CGI stuff.. CGI.pm DOES do mod_perl as well
(although I personally have no experience with this)

Stick to CGI.pm or even better, Apache::Request :)

my 2 cents


On 8/31/06, Jay Scherrer <ja...@scherrer.com> wrote:
> Daniel B. Hemmerich wrote:
> >
> > Anyone have a code snippet of a routine that will parse both POST and
> > GET user input and place it into a hash?
> >
> >
> >
> > Thanks!
> >
> >
> >
> I have used "cgi-lib.pl" from <http://cgi-lib.berkeley.edu> for awhile now.
> Jay Scherrer
>


-- 
Hendrik Van Belleghem
Spine - The backbone for your website - http://spine.sf.net

Re: Receiving user input

Posted by Jay Scherrer <ja...@scherrer.com>.
Daniel B. Hemmerich wrote:
>
> Anyone have a code snippet of a routine that will parse both POST and 
> GET user input and place it into a hash?
>
>  
>
> Thanks!
>
>  
>
I have used "cgi-lib.pl" from <http://cgi-lib.berkeley.edu> for awhile now.
Jay Scherrer