perlquestion
rovf
<blockquote><i>
</i></blockquote>
The following loop does not terminate:
<p>
<code>
# endless loop here
while(my ($r,$s) = each(%{ {x=>5,y=>8}})) {
print($r);
};
</code>
The idea here is to denote the hash verbatim, without introducing a new variable, but this doesn't work. I believe the reason is that on each the hash constructed anew, and $r never advances to the next element. Of course I could code it like this:
<code>
# this works
my $h={x=>5,y=>8};
while(my ($r,$s) = each(%{ $h })) {
print($r);
};
</code>
(or don't use references at all), but my question is: Is it possible to code this loop without naming the hash?
</p>
<div class="pmsig"><div class="pmsig-683288">
-- <br>
Ronald Fischer <ynnor@mm.st>
</div></div>