*A:: = $bak
runs.
For example:
BEGIN { my $bak; *A:: = $bak; BEGIN { $bak = \%A::; *A:: = \%a::b::c::d::e::f::; } A::g(); A->g(); }
This prints:
I am a::b::c::d::e::f::g. I am A::g.
...because the call to A::g()
is resolved at compile time, but the call to A->g()
is resolved at runtime.
BEGIN { my $bak; *A:: = $bak; BEGIN { $bak = \%A::; *A:: = \%a::b::c::d::e::f::; } sub A { return 'a::b::c::d::e::f'; }A::g();
A->g();
}
That could also conceivably be done in a package.
What am I missing?
]]>For example, List::MoreUtils uses Exporter::Tiny, so you can do this:
use v5.10; use strictures;my %LMU;
use List::MoreUtils { into => \%LMU }, -all;# calls List::MoreUtils::uniq()
say for $LMU{uniq}->(qw/foo bar foo baz/);