开发者

How can I determine which package my constructor was called from?

I got a package called 1.pm in that t开发者_开发技巧he constructor is calling a subroutine which is in the same package.

Now, if some other classes say 2.pm is calling the constructor defined in 1.pm, how can I determine if the subroutine is called from 2.pm?


Use the caller builtin:

$package = caller;

If you want more information you can use:

($package, $filename, $line) = caller;

See perldoc -f caller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜