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 ## .... ..... }
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?sub USERID { $USERID = Utility::Single_Input('Input Account Name', $USERID, $REQ +UIRED); print "UserInput entered is $USERID \n"; }
In reply to Strange behaviour with modules by Iconx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |