Hello, I've got a strange possibly obvious problem here. I'm trying to cleanup a perl application and I'm not getting the variable passed to another module for some reason. This thing is kind of a maze but its getting better. Heres a brief rundown:
mat.pl -------------- use lib "lib"; use Utility; use Add; use Group; Add::Add_Acct();
lib/Add.pm -------------- package Add; ### I tryed exporter here with no luck, maybe I did it wrong? ### require Exporter; @ISA = qw(Exporter); @EXPORT = qw($USERID); sub Add_Acct { print "Adding an Account"; &ID; &LAST ; &FIRST; ##a prior dev did this sub calling, its crap I know # +## &USERID; ##This sub takes user input ## print "ID: $ID - UserID: $USERID \n"; ## All vars defined and as e +xpected here ## Group::Groups(); .... ...
lib/Group.pm ------------------- package Group; sub Groups { print "ID: $ID - USERID: $USERID \n"; ### $ID is ok but $USERID is undefined ## .... ..... }
sub USERID { $USERID = Utility::Single_Input('Input Account Name', $USERID, $REQ +UIRED); print "UserInput entered is $USERID \n"; }
Ok so a main program Mat.pl calls the Add.pm module which loads some variables from other subroutines and then calls another module, Group.pm . Right before it calls the other module both $ID and $USERID are defined and good. Once it gets into the Group module the $USERID variable is not defined, its just empty yet $ID seems ok. Whats going on here. Maybe I should add that the &USERID subroutine takes user input, but the user input is returned just fine to the Add_Acct sub and its defined right before the call to Groups. What am I missing here?

In reply to Strange behaviour with modules by Iconx

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.