tie would affect performance of the script, especially if you tie every variable in it. Plus, there is no way to automatically tie every variable either. The problem is lexicals; you can't override my to coerce it into calling the tie constructor. So you'll have to manually tie every variable you're interested in. If you're interested in every variable, tie them all. But expect that to be a drag on the script's performance. The performance hit comes from the fact that variable access will now have all this extra work attached to it. You can't escape that.

One strategy is to use a debug flag. If the script is invoked with the -tie flag (for example), your code would go ahead and tie every variable that you set up to do so. And if the script isn't invoked with the -tie flag, your script would skip the code that ties the variables you need to watch. That's just a matter of you coming up with the proper logic to make that happen.

Is it possible that your problem has some other solution? What exactly are you really trying to do, that is requiring you to watch every single variable in the script?


Dave


In reply to Re^3: Knowing when variables change? by davido
in thread Knowing when variables change? 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.