in reply to Re^4: Making a variable in a sub retain its value between calls
in thread Making a variable in a sub retain its value between calls
I'm talking about program run-time, not any file's run-time. If you have a module Foo that uses INIT you'll get a "Too late to run INIT block" warning if you require Foo during program run-time. E.g. you have
That won't execute like one would hope. By using INIT to initialize variables to constants you impose a completely unnecessary constraint on your module. No module that uses your Foo can be loaded at program run-time, meaning you can't ever use Foo, directly or indirectly, in any module that is dynamically loaded (like plugin modules). That's quite a serious limitation.# Foo.pm INIT { print 'Foo' } # foo.pl require Foo;
There's absolutely no reason, in general, for the initialization of the typical static variable to not happen at compile-time.
ihb
See perltoc if you don't know which perldoc to read!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Making a variable in a sub retain its value between calls
by tlm (Prior) on Apr 19, 2005 at 00:36 UTC | |
by ihb (Deacon) on Apr 19, 2005 at 00:44 UTC | |
by tlm (Prior) on Apr 19, 2005 at 01:22 UTC | |
by ikegami (Patriarch) on Apr 19, 2005 at 04:49 UTC | |
by tlm (Prior) on Apr 19, 2005 at 05:46 UTC | |
|