in reply to Re: Optimization, side-effects and wrong code
in thread Optimization, side-effects and wrong code
Your code creates an infinite loop, though, if $self->{$k}->{blahblah} never evaluates to true. (whereas the OP's falls through to "return undef;")
perl -Mstrict -lw my %self; $self{$_}{blahblah} = 0 for qw/1 2 3/; while (my $k = each %self || each %self) { print "testing:$k"; print "true for $k" and last if $self{$k}{blahblah}; } __OUTPUT__ testing:1 testing:3 testing:2 testing:1 testing:3 testing:2 testing:1 ... etc. ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Optimization, side-effects and wrong code
by bpphillips (Friar) on Oct 01, 2004 at 19:54 UTC |