NAME

caller - get context of the current subroutine call


SYNOPSIS

caller EXPR

caller


DESCRIPTION

Returns the context of the current subroutine call. In a 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 a list context, returns

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

With EXPR, it returns some extra information that the debugger uses to print a stack trace. The value of EXPR indicates how many call frames to go back before the current one.

    ($package, $filename, $line, $subroutine, 
     $hasargs, $wantarray, $evaltext, $is_require) = caller($i);

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

Furthermore, when called from within the DB package, caller returns more detailed information: it sets the list variable @DB::args to be the arguments with which that subroutine was invoked.