Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Think about Loose Coupling
 
PerlMonks  

Re^4: Performance Trap - Opening/Closing Files Inside a Loop

by diotalevi (Canon)
on Dec 10, 2004 at 11:42 UTC ( [id://413902]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 $... = ...;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://413902]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.