- caller
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
evalorrequire, and the undefined value otherwise. In list context, returns# 0 1 2 ($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.
# 0 1 2 3 4 ($package, $filename, $line, $subroutine, $hasargs,# 5 6 7 8 9 10 $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller($i);Here $subroutine may be
(eval)if the frame is not a subroutine call, but aneval. In such a case additional elements $evaltext and$is_requireare set:$is_requireis true if the frame is created by arequireorusestatement, $evaltext contains the text of theeval EXPRstatement. In particular, for aneval BLOCKstatement, $subroutine is(eval), but $evaltext is undefined. (Note also that eachusestatement creates arequireframe inside aneval EXPRframe.) $subroutine may also be(unknown)if this particular subroutine happens to have been deleted from the symbol table.$hasargsis true if a new instance of@_was set up for the frame.$hintsand$bitmaskcontain pragmatic hints that the caller was compiled with. The$hintsand$bitmaskvalues are subject to change between versions of Perl, and are not meant for external use.$hinthashis a reference to a hash containing the value of%^Hwhen the caller was compiled, orundefif%^Hwas empty. Do not modify the values of this hash, as they are the actual values stored in the optree.Furthermore, when called from within the DB package, caller returns more detailed information: it sets the list variable
@DB::argsto be the arguments with which the subroutine was invoked.Be aware that the optimizer might have optimized call frames away before
callerhad a chance to get the information. That means thatcaller(N)might not return information about the call frame you expect it do, forN > 1. In particular,@DB::argsmight have information from the previous timecallerwas called.

