Instead of
map, you can use an inner
for loop. Here, the inner loop adds four
td's to an array (
@table_cells). It then wraps
@table_cells in a table row with
Tr:
use File::Basename;
# ...
while( my @cols= splice @files, 0, 4 ) {
my @table_cells;
+
for( 0..3 ) {
push @table_cells => $cols[$_]
? td( submit(-name=>'file', -value=> basename($cols[$_])) )
: td( ' ' );
}
+
print Tr( {-align=>'center'}, @table_cells );
}
Or, again, use the distributive property of
CGI's HTML functions:
while( my @cols= splice @files, 0, 4 ) {
my @table_cells;
+
for( 0..3 ) {
push @table_cells => $cols[$_]
? submit(-name=>'file', -value=> basename($cols[$_]))
: ' ';
}
+
print Tr( {-align=>'center'}, td(\@table_cells) );
}