As a Perl developer, you shouldn't have to worry about such things. If you're building something that will be using up some large amounts of memory, and you want to be sure that memory is only used while you're in a certain chunk of code, scope that variable within that chunk of code:
sub my_sub { my $variable; ... } # or if ($some_condition) { my $other_variable; ... } # $other_variable disappears when 'if' block exits!
In this example, $variable will disappear when you leave that subroutine. The memory will not be free'd in that your process's memory usage will decrease, but the memory it was using is now available to be claimed by other variables in your code.

Generally Perl's garbage collection is meant to keep the tasks of memory management away from you, so you don't have to worry about it. So long as you use strict, Perl will just about force you to declare your variables, which means you have the opportunity to scope them where they are appropriate, and let them disappear when you're done with them. You may wish to get your hands on some Perl books that talks about this in more detail, and I think it's been covered on the site a few times, so a Super Search may give you some more help.

Hope this answers your question..


In reply to Re: Re: Re: Scope of Hash variable by Fastolfe
in thread Scope of Hash variable by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.