in reply to Re: How Perl Optimize your code & some code TIPS ;-P
in thread How Perl Optimize your code & some code TIPS ;-P

while ($h = each %$rf_h) { ... }
Careful: that will bail out of the loop early if it encounters a empty '' string key. You need to parenthesize the left side to signify list context:
while (($h) = each %$rf_h) { ... }
Update: oh wow, ya learn something new every day.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: How Perl Optimize your code & some code TIPS ;-P
by ihb (Deacon) on Jan 31, 2003 at 13:44 UTC
    Nope. This is yet another particularity in Perl. This construct is given the same cure as while ($line = <FH>) { ... }.
    > perl -MO=Deparse -we'while ($foo = each %bar) { 1 }' while (defined($foo = each %bar)) { '???'; }
    Cheers,
    ihb