jdhedden's meditation from yesterday highlights one anomalous aspect of each that catches us all out at first, and in my case at least, sometimes second and third. This gets raised here every few months, and that's a good thing as the latest bunch of recruits to PM get warned of the problem.
Whilst the general concensus is that it is only a problem until you know about it, there is another, related but different expression of this anomaly that I have never seen raised here. Hence a second meditation rather than a reply to the first.
If you run the following code, it loops forever.
#! perl -slw use strict; $, = ' '; my %h; @h{ 'a' .. 'z' } = 1 .. 26; print %h; while( my $k = each %h ) { print "$k ", %h; }
Can you see why?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The anomalous each()--Part II.
by Zaxo (Archbishop) on Nov 19, 2005 at 08:14 UTC | |
by diotalevi (Canon) on Nov 19, 2005 at 20:28 UTC | |
|
Re: The anomalous each()--Part II.
by ambrus (Abbot) on Nov 19, 2005 at 14:51 UTC | |
by BrowserUk (Patriarch) on Nov 19, 2005 at 20:21 UTC | |
|
Re: The anomalous each()--Part II.
by sauoq (Abbot) on Nov 19, 2005 at 22:46 UTC |