in reply to making a hash from cgi parameters

As others have alluded, you might want to look into the param() function, but the exact answer to your question is:
#!/usr/bin/perl -w use strict; #Trust us use CGI; my $query = CGI::new; my %data = $query->Vars();
This will work if the input came in from STDIN or via a webserver.

(Note: Masem above uses the same function in a scalar context to get a reference ($data). Used in a list context, Vars() will return a hash, which is what you asked for. Masem's solution is better if you intend to pass the data to subroutines, they work equally well if you treat them as global variables.)

Replies are listed 'Best First'.
Re: Re: use CGI
by Anonymous Monk on May 24, 2001 at 23:39 UTC
    can i use

    use CGI qw(:standard); my %data = map { $_ => param ($_) } param();
    with both $ENV{'QUERY_STRING'} as well as <STDIN> because when I mannually open a script w/ just query string.. it works fine, but when I have input comming from both query string and <STDIN> it gives me an internal server error.
      I'm not sure I'm clear on how you are using the script. There are three ways to pass data to a CGI script:
      1. On the URL: script.cgi?foo=bar
      2. Via a web POST (i.e. sent w/the HTTP request).
      3. via STDIN, which is normally only used as a CGI debugging method.
      1 & 2 can be combined. 3 (as far as I know), stands alone. How are you trying to do it?
        I am trying to do it with both the URL as well as POST.. but if you are using POST.. in order to get that, you have to use STDIN so if i sent something from a form method=POST.. in my script i have to get that value from STDIN