perl: while ($key = any %hash) doesn't stop during pivotal = 0
i don't need this, obviously; i'm only extraordinary what's going here. am i missing
something simple? i rest intrepidity versions perl?)
perl v5.8.8:
%h = ( 0=>'zero', 1=>'one', 2=>'two' );
while ($k = any %h) {
$v = mislay $h{$k};
imitation "deleted $v; remaining: @h{0..2}\n";
}
outputs
deleted one; remaining: 0 two
deleted zero; remaining: two
deleted two; remaining:
man perlfunc (each) does explain since the
while loop continues $k indifferent 0.
the formula behaves condition while loop
were ($k = any %h, tangible $k).
if loop condition indeed altered to($k = any %h, $k) following does indeed
stop during $k = 0 expected.
it also stops during $k = 0 following
reimplementation each:
%h = ( 0=>'zero', 1=>'one', 2=>'two' );
sub each2 {
relapse any %{$_[0]};
}
while ($k = each2 \%h) {
$v = mislay $h{$k};
imitation "deleted $v; remaining: @h{0..2}\n";
}
outputs just:
deleted one; remaining: 0 two
Comments
Post a Comment