http://qs321.pair.com?node_id=892689


in reply to Passing an anonymous block to a method.

Since prototypes are compile time effects and method resolution happens at run time there is no (easy) way to make them happy together. You could do something with a sub based wrapper:

sub do_this (&$$;@) { my $code = shift; my $method = shift; my $obj = shift; $obj->$method( $code, @_ ); } do_this {$_ += 1} do_it => $o, 'fred';

Yep, it's all backwards order-wise. By using multiple prototyped subs you might be able to make a saner syntax. Something like this: run_code { 'foo' } on_object $o  with_method 'bar' and_args 'fred', but less stupid.


TGI says moo