Perl/CGI question

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: JD Austin
Date:  
Subject: Perl/CGI question
Heres a script that demonstrates what I think you want.


JD

#!/usr/bin/perl
         use CGI qw/:standard/; #CGI is installed by default usually.
         $query=new CGI;  # create a new cgi object
          print $query->header; # print the content header
          %namepair=undef; # this is a perl hash.. will use $namepair below.
          #an html form to show it works
          print '
<html>
<form method=post action=\'/cgi-bin/test.cgi\'>
1<input type=text name=foo1><BR>
2<input type=text name=foo2><BR>
3<input type=text name=foo3><BR>
4<input type=text name=foo4><BR>
<input type=submit name=submit value=\'submit button\'>
</form>';
          if ($query->param()) { #param what CGI holds the POST/Get data in
              @names = $query->param; #load the names into an array
              for ($i=0;$i<@names;$i++){
               #load the names/values into an associative array
                print $names[$i]."<BR>";
               $namepair{$names[$i]}=$query->param($names[$i]);
              }
              #show it actually worked:
              for ($i=0;$i<@names;$i++){
                print $names[$i].'='.$namepair{$names[$i]}."<BR>";
              }
          }





>
> I have a form that uses POST to pass two name/value pairs to a perl
> script. What is the best way to get those name/value pairs into a
> perl array? - --
> Jim
>
> Freedom is worth protecting
>
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't
> post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list -
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss