use List::Util qw(max); my $max = max (map $#$_, @LoL);