use File::Basename; # ... # 4 elements at a time while( my @cols= splice @files, 0, 4 ) { print Tr( {-align=>'center'}, map { td( $_ ? submit(-name=>'file', -value=> basename($_)) : ' ' ) } @cols[0..3] ); } #### use File::Basename; # ... while( my @cols= splice @files, 0, 4 ) { print Tr( {-align=>'center'}, td([ map { $_ ? submit(-name=>'file', -value=> basename($_)) : ' ' } @cols[0..3] ]) ); }