{ my $static; sub func { ... } }
I'd updated that to:
BEGIN { my $static= ...; sub func { ... } }
The BEGIN allows this to work just fine under mod_perl, and protects against people calling the subroutine before the $static is initialized. The subroutine is defined when it is compiled, so it is best to initialize the $static before that.
- tye
In reply to Re^2: static variable hack (BEGIN)
by tye
in thread static variable hack
by InfiniteLoop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |