How can I generate those popup menus in a single instruction (or in any case without explicitly pointing at the keys of the hashes)?#!/usr/bin/perl -w use CGI qw/ :html3 /; my %hash; my $key; my %names; my $value; my $i; foreach $i (1..10) { $key = $i % 3; $value = $i; $hash{$key} ||= []; push @{$hash{$key}}, $value; } $query = new CGI; print $query->header(); foreach $key (0..2) { $names[$key] = "key $key"; print $query->p(join( '/', @{$hash{$key}}), " modulo 3 give $key +\n"); } print $query->start_form(); # print $query->table( TR([ th(@names), td(print $query->popup_menu ( -name=>'0', -values=>[@{$hash{0}}], -default=>$hash{0}) ), td(print $query->popup_menu ( -name=>'1', -values=>[@{$hash{1}}], -default=>$hash{1}) ), td(print $query->popup_menu ( -name=>'2', -values=>[@{$hash{2}}], -default=>$hash{2}) ), # # Instead, I'd like to write a single instruction # I know this can't work ... it's just a note # # td($query->popup_menu ( -name=>"$key", # -values=>[@{$hash{$key}}], # -default=>$hash{$key}) # ), ]) ); print $query->end_form(); print $query->end_html();
In reply to hashes in CGI.pm by rbi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |