in reply to making a hash from cgi parameters
Check this out:
#!/usr/bin/perl -w ############################################################### use strict; use CGI; use Data::Dumper; my $cgi=new CGI; my $v={}; map { my($k,$vl) = ($_,$cgi->param($_)); $v->{$k}=$vl; } $cgi->param(); print Dumper($v);
Running this a couple of different ways you get:
and[pberghol@webdev0]:[~] -$ echo " > a=foo > b=junk > c=rats > d=golf > " | perl doParse.pl (offline mode: enter name=value pairs on standard input) $VAR1 = { 'a' => 'foo', 'b' => 'junk', 'c' => 'rats', 'd' => 'golf' }; [pberghol@webdev0]:[~]
[pberghol@webdev0]:[~] -$ perl doParse.pl first=peter last=berghold hobby=cooking $VAR1 = { 'first' => 'peter', 'hobby' => 'cooking', 'last' => 'berghold' }; [pberghol@webdev0]:[~] -$
Is this what you were after? HTH
| Peter L. Berghold | Schooner Technology Consulting, Inc. |
| Peter@Berghold.Net | www.berghold.net |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: use CGI
by davorg (Chancellor) on May 25, 2001 at 01:47 UTC | |
|