Newbie said:
thanks 4 ur replies... but thats not working... something trivial is
Oh please... use complete English words. This kind of baby talk has
been out since the last 300 Baud modems disappeared from the market.
going wrong somewhere
i m doing it from scratch. m creating 2 files A.pl:
#!/user/local/bin/perl
^
You mean "/usr/...".
Don't call your module "B". More generally, don't call your module
like an existing module. The Perl standard distribution has a module
B.pm, and that is loaded, not yours.
my $varA = "cfgA";
$B::varG = "cfgG";
print "Inside PL file....varA = $varA\n";
print "Inside PL file....varG = $B::varG\n";
&B::test ();
and B.pm:
package B;
local $varG;
@EXPORT = qw (&test $varG);
If you want to export, you must load the Exporter module. "require Exporter"
is missing. You also need to let your module inherit the import() routine
from Exporter. "BEGIN { our @ISA = qw( Exporter) }" is missing. See
"perldoc Exporter". You should always look at the documentation of things
if something isn't working as you expect.
The failure to use Exporter correctly is irrelevant here, because you
never call the exported version of test(), you are calling it fully
qualified.
sub test () {
print "a: $main::varA\n";
print "varG = $varG\n";
}
1;
running A.pl, it gives:
Undefined subroutine &B::test called at A.pl line 12.
Because the B.pm you actually loaded doesn't define a test() subroutine.
P.S.: I have set the env var PERL5LIB=mydir
Why would that matter? Is B.pm in mydir?
Anno