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

Re: Lexicals in if() scope gotcha!

by simonm (Vicar)
on Mar 31, 2004 at 00:36 UTC ( #341158=note: print w/ replies, xml ) Need Help??


in reply to Lexicals in if() scope gotcha!

Yikes! I've used the if ( my $foo = ... structure here and there in my code under the assumption that it would be scoped so as to DWIM; I'll have to keep my eye out for this...

Update: On second thought, this is less of a problem than it seemed at first; all of those uses are within subroutine blocks that will ensure the referenced values don't stick around forever.


Comment on Re: Lexicals in if() scope gotcha!
Re: Re: Lexicals in if() scope gotcha!
by hossman (Prior) on Mar 31, 2004 at 00:46 UTC

    Careful with your wording, the variable does go out of "scope" at the end of the "if" block, but the object refrenced by that variable refrences does not neccessarily get garbage collected.

    (As opposed to old ANSI C, where the variable itself was still in scope ... oy, those days sucked.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://341158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2014-08-23 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls