in reply to Is modifying the symbol table to redefine subroutines evil?
Aspect would be the Perl way to do this, but I don't know how to remove advice with it, so I'll demonstrate using Dojo. This is a Javascript library.
function foo () { ... }; function call_only_once () { dojo.event.disconnect( 'before', foo, call_only_once ); // Do stuff here }; dojo.event.connect( 'before', foo, call_only_once ); foo();
|
|---|