Simpler, or did I miss something?
#! perl -slw
use strict;
$, = ' ';
sub a{ 'a' }
sub b{ 'b' }
sub c{ 'c' }
sub d{ ( a, b, c ) };
sub localize {
no strict 'refs'; no warnings 'redefine';
A: local *{ +shift } = sub{ 'changed' };
goto A if @_ > 1;
+shift->();
}
print d;
print localize qw[a b c], \&d;
print d;
print localize qw[a c], \&d;
print d;
__END__
C:\test>junk
a b c
changed changed changed
a b c
changed b changed
a b c
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|