peek_our#
Return every our variable in scope at a given call-stack depth as a hash of name-to-reference pairs.
תקציר#
use PadWalker qw(peek_our);
my $h = peek_our($level);
מה מוחזר#
A hash reference keyed on sigiled variable names, with values that are references to the package variables those our declarations alias. Dereferencing reads from the package slot; assigning through the reference writes back to it.
דוגמאות#
package Main;
our $config = 'ok';
my $h = peek_our(0);
print ${ $h->{'$config'} }; # ok
Inspect a caller’s our variables:
sub show_our {
my $h = peek_our(1);
print join ",", sort keys %$h;
}
מקרי קצה#
$levelworks exactly as inpeek_my-0for the current scope,1for the caller, and so on.ourdeclarations are resolved through the package stash in effect at the declaration site, not the calling site.A package with an
ourname but no value yet appears in the hash with a reference toundef.
הבדלים מן ה-upstream#
Fully compatible with upstream PadWalker 2.5.
ראו גם#
peek_my- the sibling formyvariables.var_name- resolve a reference back to its declared name.