perl 5.24.0 on linux
Perl module "nesting" (sort of) problem... I can't seem to get this to work and was wondering if someone could tell me what's wrong. The simple example below will articulate my problem better than my verbage...
First, ping.pl...
#!/usr/bin/env perl
# This is ping.pl
use ping_mod;
ping_dbh();
exit;
Next up is the perl module, ping_mod.pm...
#!/usr/bin/env perl
use Exporter;
use ping_common;
package ping_mod;
@ISA = qw(Exporter);
@EXPORT = qw(ping_dbh);
sub ping_dbh {
set_dbh();
print "dbh = $dbh\n";
}
1;
Finally is ping_common.pm which ping_mod uses...
#!/usr/bin/env perl
use Exporter;
our $dbh;
package ping_common;
@ISA = qw(Exporter);
@EXPORT = qw($dbh set_dbh);
sub set_dbh {
$dbh = 99;
}
1;
When I run ping.pl, I get...
Undefined subroutine &ping_mod::set_dbh called at ping_mod.pm line 11.
But if I change ping_mod.pm to be...
#!/usr/bin/env perl
use Exporter;
use ping_common;
package ping_mod;
@ISA = qw(Exporter);
@EXPORT = qw(ping_dbh);
sub ping_dbh {
# set_dbh();
# print "dbh = $dbh\n";
print "hi there\n";
}
1;
... it runs fine. So, I'm thinking it must be exporting OK. But "useing" ping_common messes it up somehow.
Even if I "use ping_common" in ping.pl, it still can't find it.