Passing Array Via CGI.pm

S

shade

Hello all,

I'm a Perl newbie here and have a quick question regarding CGI.pm.

I have a CGI script that passes an array to another CGI script as
follows:

# sender.cgi
.... (snipped code)
my @fruit = ('apple','orange','pear');
print $q->startform( -action=>'receiver.cgi' ),
$q->submit( -name=>'Export Data' ),
$q->hidden( -name=>'xlfruit' value='@fruit' ),
$q->endform;
.... (snipped code)

# receiver.cgi
.... (snipped code)
my @fruit = param( 'xlfruit' );
print @fruit\n;
print @fruit[0]\n;
.... (snipped code)

The values of the fruit array pass through okay to the new CGI script
but come as a single list. I.e. the out of print @fruit[0] is the
whole line (apple orange pear) rather than just apple. It doesn't
look like the variable is still an array after the pass. Is this
normal or am I missing something?

Thanks for any help.
Tom
 
T

Tad McClellan

shade said:
I'm a Perl newbie here

http://mail.augustmail.com/~tadmc/clpmisc.shtml


$q->hidden( -name=>'xlfruit' value='@fruit' ),
^^^^ ^^

Do not re-type Perl code

Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.


Like this one.

You are missing comma (,) and greater than (>) characters.
 
T

Tad McClellan

Purl Gurl said:
You have missed other problems which are clearly evident.


No I didn't.

I stopped reading the article as soon as I saw that the
code presented could not be the real code. [1]

If the OP can't be troubled to post the actual code they want
to discuss, then I'll let somebody else help them, and move
on to helping one of the more conscientious posters.




[1] many people will do that silently, which is why the Posting
Guidelines suggest you avoid it. :)
 

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,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top