Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic


by gods
on Aug 24, 1999 at 22:43 UTC ( #359=perlfunc: print w/replies, xml ) Need Help??


See the current Perl documentation for caller.


caller - get context of the current subroutine call

caller EXPR


Returns the context of the current subroutine call. In scalar context, returns the caller's package name if there is a caller, that is, if we're in a subroutine or eval() or require(), and the undefined value otherwise. In list context, returns



     $hasargs, $wantarray, $evaltext, $is_require) = caller($i);

Here $subroutine may be "(eval)" if the frame is not a subroutine call, but an eval(). In such a case additional elements $evaltext and $is_require are set: $is_require is true if the frame is created by a require or use statement, $evaltext contains the text of the eval EXPR statement. In particular, for a eval BLOCK statement, $filename is "(eval)", but $evaltext is undefined. (Note also that each use statement creates a require frame inside an eval EXPR) frame.


Be aware that the optimizer might have optimized call frames away before caller() had a chance to get the information. That means that caller(N) might not return information about the call frame you expect it do, for N > 1. In particular, @DB::args might have information from the previous time caller() was called.

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2019-09-22 11:51 GMT
Find Nodes?
    Voting Booth?

    Results (273 votes). Check out past polls.