CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Stange Module behaviour



Mar 6, 2014, 12:12 PM

Post #1 of 2 (3752 views)
Stange Module behaviour Can't Post

I'm Cross-posting this on DevShed and perlmonks for some more feedback. You never know when someone will have more information to jolt an idea. I got a good response on perlmonk and I see that it has to be re-written, just trying to be more incremental about it, theres alot to this app.
-------------- cut ------------

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:

use lib "lib";
use Utility;
use Add;
use Group;


package Add;
### I tryed exporter here with no luck, maybe I did it wrong? ###

require Exporter;
@ISA = qw(Exporter);

sub Add_Acct
print "Adding an Account";
&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 expected here ##

package Group;
sub Groups
print "ID: $ID - USERID: $USERID \n";
### $ID is ok but $USERID is undefined ##

$USERID = Utility::Single_Input('Input Account Name', $USERID, $REQUIRED);
print "UserInput entered is $USERID \n";

Ok so a main program calls the module which loads some variables from other subroutines and then calls another module, . 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?

(This post was edited by FishMonger on Mar 6, 2014, 1:01 PM)

Veteran / Moderator

Mar 6, 2014, 1:10 PM

Post #2 of 2 (3745 views)
Re: [Iconx] Stange Module behaviour [In reply to] Can't Post

Difficult to say what the problem is with such incoherent code and description.

Please reduce your code down to a small set that compiles and demonstrates your problem. That will allow us to test your code, if needed, and tell you whats wrong.

One major problem I do see in your posted code is that it's missing:

use strict; 
use warnings;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives