in reply to Rebinding closures, possible?
That's the beauty of perl: eval gives you dynamic lexical scoping for free. Additionally, closures let you fix a dynamicaly lexically scoped entity to a static lexical scope, as you please! (That's exactly what I've done above.)my $code = q{ # some generic sub my ($param1,$param2) = @_; do_stuff($param1); do_more_stuff($param2); return whatever_you_return_from($param1,$param2); }; # ... my $closure_to_this_scope = eval "sub {$code}"; # ... my $closure_to_this_other_scope = eval "sub {$code}";
------------ :Wq Not an editor command: Wq
|
|---|