foreach my $key (keys %Hash){ $length = $#{$Hash{$key}} + 1; push @hasharraylengths, $length; }