If you are following good programming guidelines, then you don't even have to worry about this. What do I define as 'good programming guidelines' in regards to this case? Put simply: the use of subroutines. If you split up your scripts into several subroutines as any well-behaving programmer would do, then your structures will not exist for long, as perl's garbage collecting schemes will take care of everything on its own.

Just minimize/vaporize your use of global package variables and you'll be happier than an ape with a bunch of bananas (I was thinking along the lines of 'more fun than a barrel of monkeys', with 'happy' instead of 'fun').

Update: As bart mentions in his reply, the actual area to focus on is scope rather than subroutines. This is what I was implying by the use of well-structured scripts with well-scripted subroutines. Subroutines themselves contain within themselves a scope, so that once execution of a subroutine is complete, the scope is exited as well. IMO, subroutines are simply the best way to enforce scope, as opposed to using many { my $a = "hi"; } type blocks. As an additional comment, packages themselves are another great way of implementing scoping. If you've got a lot of code you reuse all the time, create a package out of it. A thank you goes out to bart for further clarifying.


In reply to Re: Garbage Collection on Hash delete by Coruscate
in thread Garbage Collection on Hash delete by netoli

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.