I'm having trouble controlling a module with package variables. The var is declared in the module with use vars and resides in @EXPORT_OK as usual and one of the module subs checks the var to make decisions. When scripts use the module, the first sub call prints a menu and uses the var properly, but when calling other subs via the menu the var is somehow ignored:
use Module; $Module::configvar = 1; print Module::menu(); # <- this works, configvar is set, but # not when invoking other subs from the options in menu().
The var is declared in the module but not defined. Some sub just asks if ($Module::configvar), which works, but only for the call to menu() made from the script. AFAIK the var is not being redefined anywhere in the module and it's not a persistent environment so... I'm stumped.

Hope this is enough information to spot my dumb mistake. I wrote a test module and script which worked as expected: the var was seen by other subs when invoked by the initially called sub. So I seem to know what I'm doing but dunno what's wrong with this module and can't post the actual code. Thanks for your consideration.


In reply to package variable does not persist 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.