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

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


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

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-08-28 06:14 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (335 votes), past polls