in reply to Re: Parsing barewords as sub/method calls?
in thread Parsing barewords as sub/method calls?

> That looks difficult to achieve.

yeah not trivial, you need to temporarily redefine AUTOLOAD in the callers package:

use strict; use warnings; use feature 'say'; package DSL; our $AUTOLOAD; sub within (&) { my $c_block=shift; #say my $call_pkg=((caller)[0]); # use B::Deparse; # say B::Deparse->new()->coderef2text($c_block); no warnings qw/redefine once/; no strict qw/refs/; local *{ ${call_pkg} . "::AUTOLOAD" } = sub { say "Autoload called as $AUTOLOAD(@_)" }; $c_block->(); } package TEST; DSL::within { &BLA; BLUB(2,3,4); }; # with import sub within (&); *within=\&DSL::within; within { &BLAi; BLUBi(2,3,4); }; BLX(); __END__ Autoload called as TEST::BLA() Autoload called as TEST::BLUB(2 3 4) Autoload called as TEST::BLAi() Autoload called as TEST::BLUBi(2 3 4) Undefined subroutine &TEST::BLX called at /home/lanx/perl/exp/DSL.pl l +ine 48.

Cheers Rolf

( addicted to the Perl Programming Language)

updates

code extended