Eric Pozharski <> wrote:
> wrote:
> *SKIP*
> > Making it safe to delete the one just returned required a special case
> > in the hash code guts, while deleting anything else is "naturally"
> > safe. Adding, on the other hand, is something best avoided.
>
> (Just opening one more DGBI war)
What's a DGBI war?
>
> First I picked that:
>
> perl -wle '
> %x = qw(a b c d e f);
> $z = 0;
> while($y = each %x) {
> print "$y => $x{$y}";
> $x{$z++} = $z++ if $z < 10; }
> '
> e => f
> 1 => 0
> c => d
> a => b
> 3 => 2
> 7 => 6
> 9 => 8
> 5 => 4
>
> I don't know what's going on here.
I don't know what part you don't know. Could you be more specific.
> The second, I believe, should be
> more clear:
And I don't *what* you think will be made clear.
>
> perl -wle '
> %x = qw(a b c d e f);
> %y = qw(z y x w v u);
> while($z = each %x) {
> print "$z => $x{$z}";
> $z = each %y;
> defined $z or next;
> $x{$z} = $y{$z}; }
Here, the value of $x{$z} is changed, but no *keys* are added or deleted
from %x while it is being iterated over by each.
> '
> e => f
> c => d
> a => b
> x => w
> v => u
> z => y
>
> What surprises me most, is key-messing in first case, which doesn't show
> in second.
Which key do you consider to be missing? Adding to a hash can give
"weird" results, but your first example doesn't illustrate that in any way.
Are you confusing yourself with the increment operator and order of
execution? Sorry, I just don't see what you are seeing in that data.
Xho
--
--------------------
http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.