PadWalker
Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.
PadWalker provides introspective access to lexical variables in Perl subroutine pads (scratchpads). It is widely used by debugging tools, test frameworks, and REPL implementations.
Implemented Functions
peek_my(N)— hashref ofmyvars at call depth Npeek_our(N)— hashref ofour(package) vars visible at call depth Npeek_sub(\\&sub)— hashref of all pad vars in a CVclosed_over(\\&sub)— hashref of only the captured (closed-over) varsset_closed_over(\\&sub, \\%h)— replace closed-over vars from a hashrefvar_name(N, \\$ref)— find the name of a variable by reference identity
Semantics
peek_my(0) returns variables in the calling scope (the Perl sub that
called peek_my). interp.hot.pad is the current frame (level 0), and
call_stack[len - N].saved_pad gives level N’s pad.
Values in the returned hashref are live references so that mutations
like ${$h->{'$x'}} = 42 update the actual variable in the target scope.
For array slots (@arr), the value is an ARRAY ref pointing to the actual Av.
For hash slots (%hash), the value is a HASH ref pointing to the actual Hv.
For scalar slots ($x), the value is a SCALAR ref via the live cell.
Reference
See perl5-modules/PadWalker-2.5/PadWalker.xs for the original XS algorithm.