PERL CGI variables to $FORM{}

Posted on 2006-05-25
Last Modified: 2010-04-17
I was using...

read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
$str= "$ENV{'QUERY_STRING'}&$buf";
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;
 foreach $key (keys %$query) {

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

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

Question by:Bob-Villa
    LVL 84

    Expert Comment

    LVL 84

    Accepted Solution

    foreach $key ($query->param) {

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    squareUp  challenge 22 81
    How to split this in C++ 4 52
    array6 challenfge 6 48
    wordlen challenge 3 30
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now