Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: simplifying a CGI param request

by brian_d_foy (Abbot)
on Apr 07, 2006 at 17:24 UTC ( [id://541932]=note: print w/replies, xml ) Need Help??


in reply to simplifying a CGI param request

You don't need to store these in separate variables to use them. Just access the right thing with param when you need it:

foreach my $number ( 1 .. 25 ) { my $value = param( "q$number"); print "q$number: $value\n"; # or, without $value # printf "q%d: %s\n", $number, param( "q$number" ); }

If you really must import these, you could use an array (since you know they are ordered). You can fill in the element with index 0 with undef just to keep the numbers straight.

my @array = ( undef, map { scalar param("q$_") } 1 .. 25 );

If you really wanted these things in a variable, you can use the CGI::import function to do it all at once. It ends up creating package variables though, so it's usually not a good idea.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://541932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found