my @array = map {int rand 1e6} 1..400000; ... $lookup_table{$_}++ for @array; #### my %lookup_table = map {int rand 1e6 => 1} 1..400000;