http://qs321.pair.com?node_id=172077


in reply to map, grep, for, foreach

How about even more simply and efficiently using methods provided by CGI.pm ...

my %input = CGI::Vars;

The above performs the same as your proposed code but ties your array in with that used internally within CGI.pm for the storage of CGI parameters.

Of the proposed code samples provided however, map and grep would be poor choices as, in the examples given, these are being used in a void context, the return values built and returned by these functions discarded. With regard to for and foreach, according to perlsyn, foreach is merely a synonym for for, the choice between the two representing a balance for the programmer between readability and brevity.