-
-
Save foursixnine/0ea0bf80765370702b2e44ffdbe79c8e to your computer and use it in GitHub Desktop.
Module export test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package PackageTesting::A; | |
use strict; | |
use warnings; | |
use Exporter qw(import); | |
our @EXPORT = qw(a b); | |
sub whowasi { ( caller(2) )[3] } | |
sub a { | |
my ($called_from) = whowasi(); | |
my $var = shift; | |
print "Calling PackageTesting::A::a with $var called from: $called_from\n"; | |
b("Within PackageTesting::A::a"); | |
} | |
sub b { | |
my ($called_from) = whowasi(); | |
my $var = shift; | |
print "Calling PackageTesting::A::b with $var called from: $called_from\n"; | |
} | |
1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package PackageTesting::B; | |
use strict; | |
use warnings; | |
use Exporter qw(import); | |
our @EXPORT = qw(main b); | |
sub whowasi { ( caller(2) )[3] } | |
sub main { | |
my ($called_from) = whowasi(); | |
my $var = shift; | |
print "Calling PackageTesting::B::Main with $var called from: $called_from\n"; | |
} | |
sub b { | |
my ($called_from) = whowasi(); | |
my $var = shift; | |
print "Calling PackageTesting::B::b with $var called from: $called_from\n"; | |
} | |
1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calling PackageTesting::A::a with : A should be from PackageTesting::A called from: main::test_sub | |
Calling PackageTesting::A::b with Within PackageTesting::A::a called from: PackageTesting::A::a | |
Calling PackageTesting::B::Main with : Main should be from PackageTesting::B called from: main::test_sub | |
Calling PackageTesting::B::b with : B should be from PackageTesting::B called from: main::test_sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use PackageTesting::A; | |
use PackageTesting::B; | |
sub test_sub{ | |
a(": A should be from PackageTesting::A"); | |
main(": Main should be from PackageTesting::B"); | |
b(": B should be from PackageTesting::B"); | |
} | |
test_sub(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
now try to call
B::b
fromA::b
and callA::a
fromB::main