Eythil has asked for the wisdom of the Perl Monks concerning the following question:
I tried to use clone on the hash to get around the problem, but it did not work. What is the best way to get around this problem (not iterating twice is not an option at the moment)?my %test = ('a' => {'b' => 'b'}); while ( my $name, $value ) = each(%test) ) { print $name1; while ( my ( $name2, $value2 ) = each(%test) ) { print $name2; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Nested while each over a hash -> infinite loop
by davido (Cardinal) on Jun 10, 2011 at 08:04 UTC | |
by Eythil (Acolyte) on Jun 10, 2011 at 08:09 UTC | |
by davido (Cardinal) on Jun 10, 2011 at 08:12 UTC | |
by Eythil (Acolyte) on Jun 10, 2011 at 08:39 UTC | |
by davido (Cardinal) on Jun 10, 2011 at 09:15 UTC | |
| |
by davido (Cardinal) on Jun 10, 2011 at 08:51 UTC | |
|
Re: Nested while each over a hash -> infinite loop (fixed)
by BrowserUk (Patriarch) on Jun 10, 2011 at 08:42 UTC | |
|
Re: Nested while each over a hash -> infinite loop
by choroba (Cardinal) on Jun 10, 2011 at 08:09 UTC |