in reply to Multiple CGI parameters

The great thing about 'use strict' is that when you know that it's being a problem, you can turn it off:

for $param (@params) { no strict 'refs'; $$param = $cgi->param($param); }

however, in your case, as everything's a scalar, I'd probably use the 'Vars' function to just dump it all to a hash: (or hashref, in this particular example)

use CGI ':cgi-lib'; $params = Vars;

Update: chromatic is completely correct. You shouldn't turn off strict unless you're sure it's a good idea, as it can get you into trouble. If you're going to use the above trick, @params should come from a list that you define, and not from a call to params() or anything that might be tainted.

Replies are listed 'Best First'.
Re^2: Multiple CGI parameters
by chromatic (Archbishop) on Aug 15, 2008 at 17:04 UTC

    Disabling strict in this way is a very bad idea. PHP used to do this, but after several years of PHP applications being broken into by malicious users automatically overwriting global variables by passing in carefully-crafted parameters, even PHP disabled this feature.

    You should not recommend that anyone do this.

Re^2: Multiple CGI parameters
by sstevens (Scribe) on Aug 15, 2008 at 16:25 UTC
    no strict 'refs';
    Now that is cool! Thanks!

    Update:
    Okay, okay, it isn't cool. I'm still just using the repetitive version.
      It's not cool. It's not big and it's not clever.

      You need to have a very good reason to turn off strict or warnings.

      This wasn't a good reason


      Unless I state otherwise, all my code runs with strict and warnings