in reply to How would you use perl debugging tools to pinpoint the problem here?

The program can be even simpler:
#!/usr/bin/perl use strict; use warnings; my %hash; $hash{$_}=1 for 1 .. 10_000_000; __END__

Your use of a hashref makes it slower because perl has to continuosly dereference it. But there's no need of any particular debugging tool to understand that the problem hast to do with your attempt to fill a hash with a huge number of keys.

The fact is that perl runs quick out of memory and starts swapping to disk. At least this is what I can infer from the music my case just started playing...

The fact that you're filling it an item at a time doesn't help either, but the keys are so many that even preassigning to keys won't help:

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

You should really consider a db based approach or a tied hash solution instead.

Also, I'm not really sure, and I may be utterly wrong, but I suspect that due to the nature of the keys, i.e. numbers, they may behave poorly to the hashing function.

Incidentally, were they not that many, I'd initialize it like thus instead:

#!/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__

(To be sure: this has the same problems as the above!)