in reply to Problem cycling through top level of nested hashes

The issue you are having is in how you are cycling over your hash. foreach my $lig (%{$ligHash}) converts the hash into a list, alternating key-value pairs. I believe what you mean to use is:

foreach my $lig (values %{$ligHash}) { DoDump($lig); }

This will feed only the sub-hashes into your subroutine (see values).

Regarding memory usage: Today, 6.5 MB is not all that much, unless you are using legacy hardware or developing toward mobile apps. The definition of "a lot" depends strongly on application.

Update: After reading almut's post above, I have to ask what is your expected output? Please read How do I post a question effectively?. Clearly two monks read your post and drew opposite conclusions as to your intention.

Replies are listed 'Best First'.
Re^2: Problem cycling through top level of nested hashes
by tomdbs98 (Beadle) on Jun 10, 2010 at 17:21 UTC
    Actually, I get the exact same output from both solutions, which works just great for me :) So thank you both.

    I end up with:

    $VAR1 = { 'R1' => { }, 'R2' => { } ... }; $VAR1 = { 'R1' => { }, 'R2' => { } ... }; ...
    However, I will be using:
    foreach my $lig (keys %{$ligHash}) { findIntersection($ligHash->{$lig}, $lig); }
    Because it gives me the option to easily pass the hash name (i.e. '34k') as a string.

    Did either of you intend on a different output? If so I would be interested in that as well.