Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by diotalevi (Canon)
on Dec 10, 2004 at 16:42 UTC ( #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
Node Status?
node history
Node Type: note [id://413902]
help
Chatterbox?
[Perl300]: Hi all
[Perl300]: I have a quick question about the Meta CPAN
[Perl300]: On any modules pod page, what does the date on top left corner below authors name indicate?
[Corion]: Likely the date of the release of the module
[Corion]: Yep, seems like that

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-12-11 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (310 votes). Check out past polls.

    Notices?