newbie: need to put form data into associative array

L

Little Monster

Hi all,
This must be a simple thing, but being very confused about CGI at the
moment, help appreciated. I need to accept POSTed form data, and put it
into an associative array. I can sort of see a long winded way of doing
it, but surely there must be a something that will do the equivalent of:

%FormData = CGI ->new();
Which appears not to work (or my form is horribly wrong!)

or need a way to turn @FormData into %FormData, whichever is easiest

You can see the current state of play at
http://www.the-monstruum.co.uk/quiz/quiz.html - not very impressive I know!

Tia,
Monster
 
A

A. Sinan Unur

Hi all,
This must be a simple thing, but being very confused about CGI at the
moment, help appreciated. I need to accept POSTed form data, and put
it into an associative array.

Reading the documentation is a good idea:

perldoc CGI

<blockquote>
Many people want to fetch the entire parameter list as a hash in which
the keys are the names of the CGI parameters, and the values are the
parameters' values. The Vars() method does this. Called in a scalar
context, it returns the parameter list as a tied hash reference. Changing
a key changes the value of the parameter in the underlying CGI parameter
list. Called in a list context, it returns the parameter list as an
ordinary hash. This allows you to read the contents of the parameter
list, but not to change it.
</blockquote>

Please read the rest of the docs. (Also available at:

http://search.cpan.org/~lds/CGI.pm-
3.05/CGI.pm#FETCHING_THE_PARAMETER_LIST_AS_A_HASH:
 
L

Little Monster

Reading the documentation is a good idea:

perldoc CGI

<blockquote>
Many people want to fetch the entire parameter list as a hash in which
the keys are the names of the CGI parameters, and the values are the
parameters' values. The Vars() method does this. Called in a scalar
context, it returns the parameter list as a tied hash reference. Changing
a key changes the value of the parameter in the underlying CGI parameter
list. Called in a list context, it returns the parameter list as an
ordinary hash. This allows you to read the contents of the parameter
list, but not to change it.
</blockquote>

Please read the rest of the docs. (Also available at:

http://search.cpan.org/~lds/CGI.pm-
3.05/CGI.pm#FETCHING_THE_PARAMETER_LIST_AS_A_HASH:

Hurrah, it works! (Though I couldn't find the doc at CPAN)
Big Thanks :) (now are you going to take the test??)

MOnster
 
D

Dave Oswald

Little Monster said:
Hurrah, it works! (Though I couldn't find the doc at CPAN)
Big Thanks :) (now are you going to take the test??)

That's so easy, I wouldn't admit to it if I weren't able to find it.

In your browser's address box type:
http://search.cpan.org

Next, in the CPAN search box type:
CGI

Click on the link to the module called CGI.

You will now see the CGI documentation, and you'll see how easy it is to
find module documentation. Now scan down the page a bit, and you'll find
the part about Vars().
 
L

Little Monster

That's so easy, I wouldn't admit to it if I weren't able to find it.

In your browser's address box type:
http://search.cpan.org

Next, in the CPAN search box type:
CGI

Click on the link to the module called CGI.

You will now see the CGI documentation, and you'll see how easy it is to
find module documentation. Now scan down the page a bit, and you'll find
the part about Vars().

That's really odd, search took me to (apparently) the exact same place
I looked before, and found it. I've gone either blind or stupd. Or both.

Monster
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top