my $max_col = (sort {$a <=> $b} map $#$_, @rows)[-1]; #### my ($max_col) = sort {$b <=> $a} map $#$_, @rows;