in reply to Re^3: Namespaces and modules
in thread Namespaces and modules
I did try what choroba suggested, and it didn't work.
I've put together three small files, for demonstration purposes:
# Test module foo package Foo; use Bar; #use Bar qw(BarFunc BarSub); BEGIN { require Exporter; # set the version for version checking our $VERSION = 1.00; # Inherit from Exporter to export functions and variables our @ISA = qw(Exporter); # Functions and variables which are exported by default our @EXPORT = qw(FooFunc FooSub); # Functions and variables which can be optionally exported our @EXPORT_OK = qw(); } sub FooFunc { return 'I am the FooFunc !'; } sub FooSub { return 'FooSub reporting in !'; } 1;
# Test module foo package Bar; use Foo; #use Foo qw(FooFunc FooSub); BEGIN { require Exporter; # set the version for version checking our $VERSION = 1.00; # Inherit from Exporter to export functions and variables our @ISA = qw(Exporter); # Functions and variables which are exported by default our @EXPORT = qw(BarFunc BarSub); # Functions and variables which can be optionally exported our @EXPORT_OK = qw(); } sub BarFunc { return "I, BarFunc, solemnly declare: ".FooFunc()."\n"; } sub BarSub { print "Howdy, Stranger !\n"; print "I'm BarSub, and I'm going to tell you a secret: '".FooSub() +."'\n"; } 1;
use Foo; use Bar; print FooFunc()."\n"; BarSub();
Now, when I run the command: perl perlTest.pl, I get the following output:
I am the FooFunc ! Howdy, Stranger ! Undefined subroutine &Bar::FooSub called at Bar.pm line 30.
Is the problem clearer now ?
EDIT:
Also, if I comment out the "use Foo;" and "use Bar;" lines from the modules, and uncomment the longer use lines (the ones with qw(...) on them), I get exactly the same output.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Namespaces and modules
by Corion (Patriarch) on Feb 09, 2015 at 15:11 UTC | |
|
Re^5: Namespaces and modules
by Anonymous Monk on Feb 09, 2015 at 15:59 UTC |