Contributed by dooberwah
on Jul 04, 2002 at 19:48 UTC
Q&A
> CGI programming
Description: In PHP (yes, I've worked in it) you can have several inputs on a webpage enter as an array in your script. All you need to do is name them like an array: using a name, square brackets and a number (foo[1], foo[2], foo[3], etc.). Is there any Perl module/module function to do this sort of thing? Answer: Input arrays to CGI contributed by jeffa CGI.pm will handle this. All you need to do is
request the multi-value parameter as a list:
use strict;
use CGI qw(param);
use Data::Dumper;
my @list = param('list');
print Dumper \@list;
Run this on the command line like so:
./foo.pl 'list=foo&list=bar&list=baz&list=qux'
and you should see the following:
$VAR1 = [
'foo',
'bar',
'baz',
'qux'
];
| Answer: Input arrays to CGI contributed by Anonymous Monk Are you posting in the right place? Check out Where should I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following: a, b, big, blockquote, br, caption, center, col, colgroup, dd, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, li, ol, p, pre, readmore, small, span, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul
Snippets of code should be wrapped in <code> tags not tags. In fact, tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible editor intervention).
Want more info? What shortcuts can I use for linking to other information? or Writeup Formatting Tips are good places to start.
|
Please (register and) log in if you wish to add an answer
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|