Re: New Quiz: "What does this code do?" (1-December-2006)

Ronald J Kimball <[email protected]> Wed, 13 Dec 2006 17:30:03 -0500
Newsgroups gmane.comp.lang.perl.qotw.discuss
Message-ID <[email protected]>
This was my answer:

--

It returns the numbers for which the corresponding parameters have a true
value.

This seems like a simpler way to do it:

my(@list) =
(
    map { /^${prefix}(\d+)$/ && $cgi->param($_) ? $1 : () }
        $cgi->param()
);

I guess it was used for handling a web form with a group of related fields,
where the user may enter a value for only some of the fields.  For example,
a list of files to upload.

--

Shlomi responded, "Actually, it was a number of checkboxes with the same
prefix for their name attribute in my case."

Which would be another example of what I guessed.  :)

Ronald