LanX has asked for the wisdom of the Perl Monks concerning the following question:
Bug or feature?
C:\>perl my $hr = {a=>1,b=>2}; $\="\n"; while ( my ($k,$v) = each %{ $hr } ) { print qq($k => $v) } __END__ b => 2 a => 1 C:\>perl $\="\n"; $x=10; while ( my ($k,$v) = each %{ {a=>1,b=>2} } ) { print qq($k => $v); die + "abort" unless $x-- } __END__ b => 2 b => 2 a => 1 b => 2 a => 1 a => 1 b => 2 b => 2 a => 1 a => 1 a => 1 abort at - line 2. C:\>perl -E"say $]" 5.032001
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Each on anonymous hash is causing endless loop.
by tybalt89 (Monsignor) on Aug 24, 2022 at 21:14 UTC | |
by LanX (Saint) on Aug 24, 2022 at 21:22 UTC | |
|
Re: Each on anonymous hash is causing endless loop.
by choroba (Cardinal) on Aug 24, 2022 at 20:57 UTC |