I've tidied the code up a bit and made the change that you requested. The simplest way to do what you wanted with the table rows is to use map as I've demonstrated below.
--#!/usr/bin/perl -w use strict; use CGI qw/ :standard /; my %hash; my $key; my %names; my $value; my $i; foreach $i (1..10) { $key = $i % 3; $value = $i; # The next line is not required due to autovivification # $hash{$key} ||= []; push @{$hash{$key}}, $value; } my @names; foreach $key (0..2) { $names[$key] = "key $key"; print p(join( '/', @{$hash{$key}}), " modulo 3 give $key\n"); } print start_form(); print table(Tr([th(@names), map { td(popup_menu(-name=>'0', -values=>[@{$hash{$_}}], -default=>$hash{$_})) } keys %hash +])); print end_form(); print end_html();
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
In reply to Re: hashes in CGI.pm
by davorg
in thread hashes in CGI.pm
by rbi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |