in reply to Overriding several methods using 'local'

Does this have the desired effect?
{ package Foo; sub f { "default f\n" } sub g { "default g\n" } } sub localized(&) { local *Foo::f = sub { "localized f\n"; }; local *Foo::g = sub { "localized g\n"; }; $_[0]->(); } localized { print STDERR Foo->f, Foo->g; }

Replies are listed 'Best First'.
Re^2: Overriding several methods using 'local'
by dmitri (Priest) on May 22, 2006 at 18:46 UTC
    It looks like this is exactly what I need. I will play with it and see. Thanks!