in reply to Re^3: Performance Trap - Opening/Closing Files Inside a Loop
in thread Performance Trap - Opening/Closing Files Inside a Loop

You're thinking of my() on statements using modifiers. The problem is avoiding only calling my() sometimes. Then the variable may retain is previous value from earlier loops in a way that is declared off-limits and buggy but never fixed because it would be too much overhead to make it consistent.

Ok

while ( my ( $k, $v ) = each %h ) { ... } while ( my $line = <> ) { ... } for ( my $ix = 0; ...; ... ) { ... }

Not ok

my $... = ... if ...; ... or my $... = ...;