Thanks for the advice and comments on my previous question on arrays in modules. I have that working, but of course, I have another question :) I'm wondering just how necessary it is to use a qualifier on a module-declared variable or array.

I understand (to some extent) qualifying the names of variables and arrays declared in modules, when accessed in a script. It seemed awfully cumbersome to me to use the qualified names, but I went at it.

While making those changes to a script, I used a module variable reference to access a module array, but forgot to add the qualifier. I didn't notice the missing qualifier until going over the script to add comments. I checked through the script and module and didn't find it malfunctioning.

So I got to thinking : would it work without the qualifier in other situations ? So far, it does.

As a test case, I modified a short script without the qualifiers, instead using an abbreviation of the subroutine name, like this:

OpenFileFillWeeklyTimeArray::$WeeklyTimeArrayRef

became

$OFFWTA_WeeklyTimeArrayRef

So far, in testing, it works. The abbreviation-prefixed name tells me right off this isn't a local variable - don't modify it or the array it references. This type of name also takes up half the space of the qualified name. And I find it easier to read the script, without the cumbersome qualified name.

But I know enough to know I don't know what I don't know.

So I'm asking here: Am I letting myself in for considerable grief down the road using this naming convention for module variables and arrays ?


In reply to Qualified module variables and arrays by DarrenSol

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.