develooper Front page | perl.beginners | Postings from January 2002

Moving CGI 'param' data into a writable hash [was:: What's wrong with this?]

Thread Previous | Thread Next
From:
Gary Hawkins
Date:
January 31, 2002 19:48
Subject:
Moving CGI 'param' data into a writable hash [was:: What's wrong with this?]
Message ID:
LOBBIJFNBAGIOILLFAIBCENPNGAA.ghawk@eskimo.com
> using the Perl4 cgi-lib.pl.  However, I can think of no other
> legitimate use.  Here's a nice,
> clean method of dealing with this:
>
>     use strict;
>     use CGI qw/:standard/;
>     my %form_data = map { $_, get_data($_) } param;
>
>     sub get_data
>     {
>         my $name   = shift;
>         my @values = param( $name );
>         return @values > 1
>             ? \@values
>             : $values[0];
>     }

That worked, thanks, but seemed to be 1/100th of a second slower than the other
method, which became distilled down to the following line, eliminating the
previous multiline and sub I was using:

	$form_data{$_} = param($_) for (param());

Iterates over the form name/value pairs in param() and places them into
%form_data.

/g




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About