use strict; use warnings; use CGI qw(:standard); print header,start_html,start_form, p( 'How many columns? ', popup_menu(-name=>'cols',-values=>[1..16]), ), submit,end_form,hr, ; my $cols = param('cols') || 4; my @one_d = map sprintf('%02x',$_) x 3, reverse (0..255); my @two_d = map[ @one_d[$_..$_+$cols-1] ], range(0,$#one_d,$cols) ; print p("there are $cols columns:"), table( map {Tr( map {td{bgcolor=>"#$_"},$_} @$_ )} @two_d ), end_html, ; sub range {grep!(($_-$_[0])%($_[2]||1)),$_[0]..$_[1]}