kamesh3183 has asked for the wisdom of the Perl Monks concerning the following question:

hi monks,
I have following tag in html form. The form uses post method to send values to the server.
<select name="users_list" multiple size="5">{users}</select>
This tag will provide users with a list to select multiple options. My question is how to get the values selected by users in perl script.
Thanks
kamesh

Replies are listed 'Best First'.
Re: how to get multiple options selected in webpage
by davido (Cardinal) on Jan 18, 2005 at 06:25 UTC

    You would use the CGI.pm module, documented here: CGI. It handles the parsing of form input, and with the param() method, hands your script the data passed by the form submission. I really recommend reading the documentation for CGI "cover to cover".


    Dave

Re: how to get multiple options selected in webpage
by mkirank (Chaplain) on Jan 18, 2005 at 06:52 UTC
    As davido has suggested , go through the CGI docs
    a quick answer to your question ,you can use something like this
    use CGI; my $cgi; my @selected_values; $cgi = new CGI; @selected_values = $cgi->param('users_list');
Re: how to get multiple options selected in webpage
by opensourcer (Monk) on Jan 18, 2005 at 07:05 UTC
    k here the code to get the users_list #--in case ur running from windows version of apache --- #!C:\perl\bin\perl.exe #-- if ur in linux versions -- #!/usr/bin/perl #using CGI standard module use CGI qw(:standard) ; #$cgi is a reference for CGI module my $cgi = new CGI; #this is a header which sends to the browser that the #content will be text/html print header(); #now ur copying the selected contents into an array my @select = $cgi->param('users_list'); #displaying them on the page in one line print @select; # or u can display like this in dirrent lines for ($i=0; $i <= $#select; $i++) { print $select[$i], "&lt;br&gt;"; }