Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Does undef free ram?

by bronto (Priest)
on Jul 17, 2002 at 12:05 UTC ( #182395=note: print w/ replies, xml ) Need Help??


in reply to Does undef free ram?

When I need to allocate variables for a limited time, for example when I need them in just a snippet of code, I usually prefer blocks and lexicals instead of undefing. For example:

{ my @needed_here = get_array() ; # do something with data, e.g. coffee(@needed_here) ; } # you are no more @needed_here ;-)

As soon as you get out of the block, @needed_here "disappears" (unless you saved some reference to it, for example in a closure)

I prefer this way instead of undefing because it looks clearer to me --when I need the variable, it's there, when I need it no more it goes away (instead of staying around undefined).

If you are interested in this approach, you could take a look at "Private Variables via my()" in perlsub

Ciao!
--bronto

# Another Perl edition of a song:
# The End, by The Beatles
END {
  $you->take($love) eq $you->made($love) ;
}


Comment on Re: Does undef free ram?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-15 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (146 votes), past polls