in reply to Re^4: Nested while each over a hash -> infinite loop
in thread Nested while each over a hash -> infinite loop

So you would benefit here from recursion:

traverse(\%my_hash); sub traverse { my $hash_ref = shift; while ( my( $key, $value ) = each %{ $hash_ref } ) { if( ref $value ) { traverse( $value ); } else { print "$key => $value\n"; } } }

Dave

Replies are listed 'Best First'.
Re^6: Nested while each over a hash -> infinite loop
by Eythil (Acolyte) on Jun 10, 2011 at 09:22 UTC
    Sorry for sending you a message earlier. Actually that should have been a reply to the thread

    Recursion is indeed the solution to my problem. Thank you very much.