Aside from agreeing with Tachyon that if you must have a stack of globals then a hash is the way to go, I was wondering if you had used sub routines or not?

Accessing and modifying globals from within a subroutine rather than passing in parameters is (IMHO) a bad thing.

Additionally, have you looked at the number of variables you have with respect to them being configuration options or constants? If you find a stack of those then it may help with your clean up as you wouldn't need to clear those and can use the constant pragma or have a configuration file instead.

From your post, I am assuming that you have to clean up once the application has finished servicing a command. Returning to its wait state ready for another command at some point in the future. Perhaps you should look specifically at this area and consider your service code as something you can put into a module. Perhaps one module per command. You can then handle cleanup of each command specifically within each module yet have a smaller global cleanup in your main servicing loop.

You may find this easier to maintain - this is an approach I have used before and its saved me many headaches. Its a bit like a strategy pattern implementation (but how far is down to you).

In reply to Re: Clearing user defined variables by simon.proctor
in thread Clearing user defined variables by Wassercrats

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.