for(my $i = 1; $i < 50; $i++) { my $start = "aaa"; my %hash; keys %hash = 250_000; ### pre-allocate the hash for(my $j = 1; $j < 250000; $j++) { my $val = "$cnt $i $j $start"; $hash{$val} = $cnt; ### Simple hash assignments $cnt++; $start++; } $h_item_selector[$i] = \%hash; ### then assign a reference }