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.