in reply to Module caller
MyModule.pm:
package MyModule; use warnings; use strict; print __PACKAGE__, ' called from ', (caller)[1], ".\n"; sub func { return 2 * shift } __PACKAGE__
script.pl:
#!/usr/bin/perl use warnings; use strict; use MyModule; warn MyModule::func(21);
Output:
MyModule called from ./script.pl. 42 at ./script.pl line 8.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Module caller
by marinersk (Priest) on May 06, 2015 at 17:50 UTC | |
Re^2: Module caller
by jeffsto (Novice) on May 07, 2015 at 13:02 UTC |