Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Passing variable to another CGI.pm program

by golux (Pilgrim)
on Nov 27, 2012 at 17:28 UTC ( #1005892=note: print w/ replies, xml ) Need Help??


in reply to Passing variable to another CGI.pm program

Hi deathmetalscottie,

Make sure that you have a name defined for the <select> tag. In your code,you're using "$key", which you never define:

my $key; ... <select name="$key" size="15" multiple="multiple">
So if you fix that, for example, calling it "multi":
my $name = "multi"; # Renamed from $key to be less confusing # Sorry, I don't want to show my /etc/password :) my %user = ( 'fred' => 101, 'barney' => 102, 'wilma' => 103, 'betty' => 104, 'pebbles' => 105, 'bambam' => 106, ); ... <select name="$name" size="15" multiple="multiple"> foreach my $key(sort keys %user) { my $val = $user{$key}; if ($val > 100) { print qq{<option value="$key">$key ($val)</option><br />}; } }
Then you can see with a quick test which names were chosen, in sum.cgi, like this:
#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser/; use Data::Dumper; my @users = param('multi'); die sprintf "Users selected: %s\n", Dumper(\@users);
For example, selecting the 2 values "bambam (106)" and "pebbles (105)":
*** bambam (106) **** barney (102) betty (104) fred (101) *** pebbles (105) *** wilma (103)
and clicking "Go!" to call sum.cgi should show:
Software error: Users selected: $VAR1 = [ 'betty', 'wilma' ];
say  substr+lc crypt(qw $i3 SI$),4,5


Comment on Re: Passing variable to another CGI.pm program
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-10-31 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (217 votes), past polls