in reply to Re^3: Performance Trap - Opening/Closing Files Inside a Loop
in thread Performance Trap - Opening/Closing Files Inside a Loop
It's rather common to stick a declaration inside the test of a (BLOCK) loop, often seen with input loops, or looping over both keys and values of a hash at the same time.# if EXPR is false $foo will still have the last set value for this sc +ope's (but not other scope's) $foo my $foo if EXPR; #same here if EXPR is false the first time it's tested on this pass. my $bar while EXPR;
while (my $foo = <$fh>) { #do something } while (my ($key, $value) = each %hash) { #do other things }
|
---|