Creating Dynamic variables from CGI.pm Param()

J

Julia deSilva

Hello All.

I use something like this to process form elements

my $field;
foreach $field ($q->param()) {
${$field} = $q->param($field);
.....
.....
}

to retreive data from a dynamically created webpage where I do not know
either the number or names of the form elements.

The above can't work under strict.

www.domain.com/cgi-bin/mail_test.cgi?XXX=1
mail_test.cgi

Some pointers would be very gratefully received.

Thanks
 
M

Mark Clements

Julia said:
I use something like this to process form elements

my $field;
foreach $field ($q->param()) {
${$field} = $q->param($field);
.....
.....
}

to retreive data from a dynamically created webpage where I do not know
either the number or names of the form elements.
Yet you're willing to create variables with the names of them without any further validation?
Even if you knew the names of the form elements, this would be a bad idea as there is nothing to
stop someone slapping up a web page anywhere that submits to your script.
The above can't work under strict. !!!!

Some pointers would be very gratefully received.
you want to check out Vars and (shudder) import_names from CGI.

Mark
 
D

David K. Wall

Julia deSilva said:
I use something like this to process form elements

my $field;
foreach $field ($q->param()) {
${$field} = $q->param($field);
.....
.....
}

to retreive data from a dynamically created webpage where I do not
know either the number or names of the form elements.

The above can't work under strict.

Exactly. Strictures exist to keep you from doing dangerous things like
that. For a discussion of why what you're doing is a bad idea, see
http://perl.plover.com/varvarname.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top