in reply to Inspecting package vars in a sub

Why do you need it?

I'm just curious. Also, I probably asked this before, but who knows what changed in the meantime :-)

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Inspecting package vars in a sub
by LanX (Saint) on Dec 04, 2020 at 22:40 UTC
    Long story, ... you know meta-programming and syntactic sugar stuff. ;)

    For instance I want to be able to automatically localize special package vars in a code-block

    sub xsub (&) { my ($code)=@_; sub { local ($a,$b) = @_; &$code; } } my $c_ref = xsub { $a ** $b }; say $c_ref->(2,3); #> 8

    This looks better than sub { $_[0] ** $_[1] }

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery