Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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.

Replies are listed 'Best First'.
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?
[erix]: fortunately, Putin seems to be ill -- or at least, they're building a hospital for him and his cronies in Moscow
[erix]: nobody knows what kind it takes :)
[erix]: I say his seems a face that launches a thousand missiles :)
[Your Mother]: I say I do. :P
[Your Mother]: Missiles would be an idiotís play. Putin is many things but he is not an idiot.
[erix]: I like the idea of the trumps troup of imbeciles growing slightly nervous now their incompetence will be tested
[erix]: you seem forget there is another idiot coming :)
[Your Mother]: The US government does not attract talent, but grafters and liars and it has been that way for the better part of a century. FEW exceptions.
[erix]: you think it only /looks/ worse this time?
[Your Mother]: HR Clinton was literally threatening Russia. She would have been MUCH more likely to start real trouble.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-01-20 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (173 votes). Check out past polls.