It'll be easier to avoid this sort of bothersome (and embarrassing) glitch if you try one or more of the following strategies when writing your code:

Regarding the second point, maybe that long declaration line you posted is already properly "localized", such that all those variables really are required throughout the scope of the code block that contains that line. But if that code block is a whole big long script, you might need to think more carefully about design, and how to make your code more modular. At the very least, it may still be helpful to move some declarations closer to where they actually get used.

OTOH, if you are just declaring all your variables with "my" at the top of your script regardless of where they actually get used, then you are missing out on some of the important advantages of "use strict" and lexically scoped "my" variables.


In reply to Re: Scalar dereference error by graff
in thread Scalar dereference error 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.