#!/usr/bin/perl use strict; use warnings; my %hash; $hash{$_}=1 for 1 .. 10_000_000; __END__ #### #!/usr/bin/perl use strict; use warnings; use constant KEYS => 10_000_000; my %hash; keys %hash=KEYS; $hash{$_}=1 for 1 .. KEYS; __END__ #### #!/usr/bin/perl use strict; use warnings; use constant KEYS => 10_000_000; my %hash; keys %hash=KEYS; @hash{1..KEYS}=(1) x KEYS; __END__