H
Hal Vaughan
I've had a similar problem before and now I realize it was resolved by
removing a level of modules. I don't see how I can include sample code
unless I include entire modules, but basically, when I do a "use Module;",
in some cases the functions in that Module aren't available. Here's an
example that works:
#!/usr/bin/perl
#Program: t-test
use MyMods::Log;
.....
initlog($channel); #This initializes the Log functions
Then, in MyMods/Log.pm, I have:
use MyMods::Channel;
sub initlog {
my $channel = shift(@_);
setchannelprogram($channel); #Routine in MyMods::Channel --
# used w/out problem
return;
}
When I do this, it works just fine. However, when I add another level, by
having a program use a module that uses MyMods::Log, then MyMod::Log cannot
access routines in MyMods::Channel. Here's an example of what does not
work:
#!/usr/bin/perl
#Program: t-fetch
use MyMods::Search;
......
initsearch($channel); #This initializes Search
Then, in MyMods/Search.pm, I have:
use MyMods::Log;
....
sub initsearch {
my $channel = shift(@_);
initlog($channel); #Same initchannel as before, but now
#called by a function in a module, not
#directly from the main program
return;
}
Then, in MyMods/Log.pm, again, I have the same as before:
use MyMods::Channel;
sub initlog {
my $channel = shift(@_);
setchannelprogram($channel); #Routine in MyMods::Channel --
# Now won't work when called from a mod
# that is, in turn, called from a mod
return;
}
This time I'm using the same module MyMods::Log, and that module is using
the same module, MyMods::Channel, but this time, it is NOT able to use the
functions in MyMods::Channel. All other routines in other mods are
accessible, it's just the Channel.pm file I'm having trouble with.
So what am I doing wrong? Why can MyMods::Log access MyMods::Channel when
called from a module used by program, but NOT when called from a module
that is used by a module that is used by a program?
Thanks!
Hal
removing a level of modules. I don't see how I can include sample code
unless I include entire modules, but basically, when I do a "use Module;",
in some cases the functions in that Module aren't available. Here's an
example that works:
#!/usr/bin/perl
#Program: t-test
use MyMods::Log;
.....
initlog($channel); #This initializes the Log functions
Then, in MyMods/Log.pm, I have:
use MyMods::Channel;
sub initlog {
my $channel = shift(@_);
setchannelprogram($channel); #Routine in MyMods::Channel --
# used w/out problem
return;
}
When I do this, it works just fine. However, when I add another level, by
having a program use a module that uses MyMods::Log, then MyMod::Log cannot
access routines in MyMods::Channel. Here's an example of what does not
work:
#!/usr/bin/perl
#Program: t-fetch
use MyMods::Search;
......
initsearch($channel); #This initializes Search
Then, in MyMods/Search.pm, I have:
use MyMods::Log;
....
sub initsearch {
my $channel = shift(@_);
initlog($channel); #Same initchannel as before, but now
#called by a function in a module, not
#directly from the main program
return;
}
Then, in MyMods/Log.pm, again, I have the same as before:
use MyMods::Channel;
sub initlog {
my $channel = shift(@_);
setchannelprogram($channel); #Routine in MyMods::Channel --
# Now won't work when called from a mod
# that is, in turn, called from a mod
return;
}
This time I'm using the same module MyMods::Log, and that module is using
the same module, MyMods::Channel, but this time, it is NOT able to use the
functions in MyMods::Channel. All other routines in other mods are
accessible, it's just the Channel.pm file I'm having trouble with.
So what am I doing wrong? Why can MyMods::Log access MyMods::Channel when
called from a module used by program, but NOT when called from a module
that is used by a module that is used by a program?
Thanks!
Hal