Movatterモバイル変換


[0]ホーム

URL:


functions /caller
(source,CPAN)
You are viewing the version of this documentation from Perl 5.8.2.View the latest version
#caller EXPR
#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 oreval orrequire, and the undefined value otherwise. In 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, $hints, $bitmask) = 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_require are set:$is_require is true if the frame is created by arequire oruse statement, $evaltext contains the text of theeval EXPR statement. In particular, for aneval BLOCK statement, $filename is(eval), but $evaltext is undefined. (Note also that eachuse statement creates arequire frame inside aneval EXPR frame.) $subroutine may also be(unknown) if this particular subroutine happens to have been deleted from the symbol table.$hasargs is true if a new instance of@_ was set up for the frame.$hints and$bitmask contain pragmatic hints that the caller was compiled with. The$hints and$bitmask values are subject to change between versions of Perl, and are not meant for external use.

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 the subroutine was invoked.

Be aware that the optimizer might have optimized call frames away beforecaller had 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::args might have information from the previous timecaller was called.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2026 Movatter.jp