I don't think I understand your question. I tried this:...and that works.# snip code
Of course!
Are you saying you want to do something like "$obj->sub { do_stuff(); etc(); }( @args );" so that you don't need an explicit $action?
Exactly, out of orthogonality considerations.
It seems that you're basically doing something like:"Inline" code doesn't need to be made into a sub. Am I misunderstanding your question?{ @_ = ( $obj, @args ); # rest of 'sub' goes here }
Possibly so: I certainly don't understand your reply. Are you saying that you would expect the following to work as (I) intended?
use strict; use warnings; use Data::Dumper; my $obj = bless {}, 'Foo'; $obj->{ print Dumper( \@_ ) }( 'hello' ); __END__
If so, then it doesn't because ->{ is interpreted as hash dereferencing:
$VAR1 = []; Use of uninitialized value in subroutine entry at 605841.pl line 7. Can't use string ("") as a subroutine ref while "strict refs" in use a +t 605841.p l line 7.
OTOH Anno and grinder completely addressed my question.
In reply to Re^2: Question re $obj->$action(@args) syntax
by blazar
in thread Question re $obj->$action(@args) syntax
by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |