Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Beware of global variables, for they may prevent your destruction.

by dsheroh (Prior)
on Nov 26, 2009 at 09:15 UTC ( #809511=note: print w/replies, xml ) Need Help??

in reply to Beware of global variables, for they may prevent your destruction.

I ran into just about the exact same thing a couple weeks ago (in a FastCGI app, even) and dealt with it in a slightly more direct fashion:
our $foo_global = $foo; $obj->method_that_needs_foo_but_takes_no_params; undef $foo_global;
While either way of handling this works, I prefer the undef solution for a case like mine where the global data is only needed for one specific call, as it lets me immediately clean it up after that need passes. weaken is definitely the better solution in other cases, though, where you may not know as clearly when you'll be done with the global.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://809511]
jedikaiti is glad to see the conditioning persists...
[jedikaiti]: And yes, I have saved down a copy and added it to my walpaper rotation
[zentara]: jedikaiti my condition has a condition :-)
[jedikaiti]: :-D
[Your Mother]: ♫ You say apod, I say Perl POD ... let's call the whole thing off ♬

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-08-18 15:44 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (304 votes). Check out past polls.