in reply to Re: Re: %main:: and my'd vars
in thread %main:: and my'd vars

use PadWalker qw(peek_my); do "xyz"; #this file has many hashrefs defined foreach $item (keys %{peek_my(0)}) { print $item,"\n"; print $item if (ref $item eq ref {}); }
I dont get any o/p . why is this so? Code in "xyz" file:
$a1 = { 'p' => 1, 'q' => 2, }; $a2 = { 'p' => 1, 'q' => 2, };

Replies are listed 'Best First'.
Re^4: %main:: and my'd vars
by LanX (Saint) on May 11, 2023 at 20:44 UTC
    you didn't use my for your variables.

    update

    use v5.12.0; use warnings; use PadWalker qw/peek_my peek_our/; my $a1 = {}; our $a2 = {}; for my $space ( peek_my(0),peek_our(0) ){ for my $item (keys %{$space}) { say $item if (ref ${$space->{$item}} eq "HASH"); } }

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery