in reply to Modules: computing a constant, "on load" or in new()?
Putting them in new means doing the same work over. That's a waste of cpu and a violation of DRY principle.
There is nothing 'dirty' about setting up the 'constant' requirements of your module at load time.
Indeed, that exactly what you are doing when you declare your functions.
sub XYZ { ...} is exactly the same as *{__PACKAGE__'::XYZ'} = sub { ... };; it is a load-time assignment to a symbol in your package stash.
|
|---|