in reply to Is modifying the symbol table to redefine subroutines evil?
You can change that with
but only if that's what you want ("call once per user" instead of "call once globally").no strict 'refs'; my $pkg = caller; *{ $pkg . "::foo" } = sub { ... }; # the final foo
Personally, I like the idiom
But I'll admit I always wonder whether the code is going to get run 4.3 billion times and redo the init code...sub foo { our $CALL_COUNT; call_me_only_once() unless $CALL_COUNT++; ...do stuff... }
|
|---|