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