--- name: caller status: documented runtime: pp source: src/runtime/pp/helpers.rs --- ```{index} single: caller; Perl built-in (pp runtime) ``` # caller ## Synopsis ```perl my $package = caller; # scalar: package name my ($pkg, $file, $line) = caller; # list: basic triple my ($pkg, $file, $line, $sub, ...) = caller(0); my @info = caller(1); # caller's caller ``` ## Description Returns information about the calling subroutine's context. In **scalar context**, returns the package name of the calling subroutine. In **list context**, returns a multi-element list with (at minimum) package, filename, and line number. When called with a numeric argument N, returns information about the Nth stack frame above the current subroutine: | Index | Field | |-------|----------------| | 0 | package name | | 1 | filename | | 2 | line number | | 3 | subroutine | | 4 | hasargs | | 5 | wantarray | Returns `undef` (scalar) or an empty list if the requested stack depth exceeds the actual call depth. `caller(0)` returns info from `call_stack.last()` (the current sub's frame); `caller(1)` looks one frame further up. When the op has `WANT` bits set to 0 (unknown), the context is inherited from the enclosing call frame, matching perl5 behavior. ## See also die, warn, caller