in reply to Re: Question re $obj->$action(@args) syntax
in thread Question re $obj->$action(@args) syntax
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Question re $obj->$action(@args) syntax
by kyle (Abbot) on Mar 21, 2007 at 15:07 UTC | |
by blazar (Canon) on Mar 21, 2007 at 16:40 UTC |