Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Input arrays to CGI

by dooberwah (Pilgrim)
on Jul 04, 2002 at 19:48 UTC ( [id://179527]=perlquestion: print w/replies, xml ) Need Help??

dooberwah has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

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?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: Input arrays to CGI
by jeffa (Bishop) on Jul 04, 2002 at 21:59 UTC
    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' ];
Re: Input arrays to CGI
by Anonymous Monk on Jul 08, 2004 at 11:11 UTC
    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. 
    
    
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://179527]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found