Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

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


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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-16 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found