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) ;
}
In reply to Re: Does undef free ram?
by bronto
in thread Does undef free ram?
by Xxaxx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |