sstevens has asked for the wisdom of the Perl Monks concerning the following question:
When I have a lot of parameters, copy-pasting the $cgi-param('..') over and over gets annoying quickly. Back before I put use strict; in my scripts (about three days ago), I would do the following to overcome this:use CGI; my $cgi = new CGI(); my $param1 = $cgi->param('param1'); my $param2 = $cgi->param('param2'); ..
However, now that I'm using strict, I can't do this anymore. I get an error that I can't declare a scalar dereference. I see that you can do things like:@params = ('param1', 'param2', ..); for $param (@params) { $$param = $cgi->param($param); }
ormy @names = $cgi->param;
They just aren't as convenient as the other method. With the other method, I could get all the variables and then do things like$cgi->import_names('Q');
But now I would have to do something likeprint "bla bla $param1 bla\n";
I know I'm complaining about something that really doesn't matter too much. I'm just wondering what you monks do when you retrieve a large set of parameters. Although there are a plethora of other threads that deal with getting parameters with CGI.pm, I couldn't find any that answer this question. My apologies if such a thread already exists.print "bla bla " . $Q::param1 . " bla\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple CGI parameters
by injunjoel (Priest) on Aug 15, 2008 at 18:57 UTC | |
by Joost (Canon) on Aug 15, 2008 at 19:48 UTC | |
by Cap'n Steve (Friar) on Aug 15, 2008 at 23:17 UTC | |
|
Re: Multiple CGI parameters
by jhourcle (Prior) on Aug 15, 2008 at 16:09 UTC | |
by chromatic (Archbishop) on Aug 15, 2008 at 17:04 UTC | |
by sstevens (Scribe) on Aug 15, 2008 at 16:25 UTC | |
by FunkyMonk (Bishop) on Aug 15, 2008 at 22:59 UTC | |
|
Re: Multiple CGI parameters
by Lawliet (Curate) on Aug 15, 2008 at 15:43 UTC | |
by sstevens (Scribe) on Aug 15, 2008 at 16:07 UTC | |
|
Re: Multiple CGI parameters
by Anonymous Monk on Aug 15, 2008 at 14:45 UTC |