[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

PERL CGI variables to $FORM{}

I was using...

read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
$str= "$ENV{'QUERY_STRING'}&$buf";
@pairs=split('&',$str);
foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $value =~ s/~!/ ~!/g;
  $FORM{$name} = $value;
  }

to read form input on my PERL scripts however I want to switch to the CGI module. I would like to make the switch now without breaking all of my code. I am looking for a way to alias $FORM{x} with $query->param(x).

I tried the following

 use CGI;
 $query=CGI->new();
 foreach $key (keys %$query) {
   $FORM{$key}=$query->param($key);
   }

but fail with a CGI error "Not an ARRAY reference"

looking for suggestions. Note: I will not be using multipart/form-data.




0
Bob-Villa
Asked:
Bob-Villa
  • 2
1 Solution
 
ozoCommented:
%FORM=$query->Vars;
0
 
ozoCommented:
#or
foreach $key ($query->param) {
   $FORM{$key}=$query->param($key);
   }
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now