in reply to Variable Variables
Doing something like this is bad practice, for a variety of
reasons. Mostly because if someone adds a form field that
you did not prepare for, it might affect a different part
of the script. For example, if someone added a form field
called "key" your script would die because it would try to
set $key to the form value, which is also the
loop iterator.
If you want to avoid calling $query->param() each and every time you want to access the form values, and I sympathize, you should try something like this:
use strict; use CGI; my $query = new CGI; # this will import the form values my %vars = $query->Vars(); # this will "export" the form values print "Name: ", $vars{name}, "\n";
...et cetera. See the CGI.pm manpage for more info about the Vars syntax.
HTH'kaboo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (CGI::Vars) Re: Variable Variables
by Kanji (Parson) on Dec 05, 2000 at 09:38 UTC | |
Re: (CGI::Vars) Re: Variable Variables
by Adam (Vicar) on Dec 05, 2000 at 07:50 UTC | |
by mwp (Hermit) on Dec 05, 2000 at 07:55 UTC | |
Re: (CGI::Vars) Re: Variable Variables
by repson (Chaplain) on Dec 05, 2000 at 08:15 UTC | |
Re: (CGI::Vars) Re: Variable Variables
by Anonymous Monk on Dec 06, 2000 at 01:59 UTC | |
by mwp (Hermit) on Dec 06, 2000 at 10:01 UTC |
In Section
Seekers of Perl Wisdom