in reply to Is modifying the symbol table to redefine subroutines evil?
The objective being to determine which version of foo() to use (perhaps XS, module, roll-your-own) only once so that subsequent calls are faster.sub foo { no warnings 'redefine'; if ($cond1) { *foo = sub { ... }; } elsif ($cond2) { *foo = sub { ... }; } else { *foo = sub { ... }; } goto &foo; }
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is modifying the symbol table to redefine subroutines evil?
by tlm (Prior) on Apr 11, 2007 at 22:03 UTC |