in reply to Module caller

Yes, caller should do what you want.

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

    Make sure you read the documetation on how callerworks -- knowing how many layers back to go, and what is actually supported on your platform (notably if Windows), might take some playing with it to see what you get.

Re^2: Module caller
by jeffsto (Novice) on May 07, 2015 at 13:02 UTC
    print __PACKAGE__, ' called from ', (caller)1, ".\n"; Worked perfect! Its exactly what I was looking for. Thanks!