The objects are irrelevant in this case.
Maybe it'd be enough to local()ize the variables instead of insisting that they are lexical:
{ our ($cont, $foo, $bar); my %transformations = ( xxx => sub { use_the($foo,'and', $bar); as_you_need($cont); }, ... ); } ... for my $xform (@{$self->{xforms}}) { our ($cont, $foo, $bar); local $foo = get_foo(); local $bar = get_bar(); local $cont = $container; $transformations{$xform}->(); }
I would not bother and just access $_[0], $_[1] and $_[2] within the transformations.
The only other option is a source filter and I bet you don't want to go there.
Jenda
Enoch was right!
Enjoy the last years of Rome.
In reply to Re: Perl OO: Need a concise way of representing operations on an object
by Jenda
in thread Perl OO: Need a concise way of representing operations on an object
by wanna_code_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |