in reply to Re^3: How do I initiate a constant with variable value?
in thread How do I initiate a constant with variable value?

Each module contains some code and also some init code which is executed when module "used". Doesn't this cost time?

Of couse this is not the only one place, I did some profiling and is was the reason why I started thinking about constants since there are so many places with getters and similar things.

  • Comment on Re^4: How do I initiate a constant with variable value?

Replies are listed 'Best First'.
Re^5: How do I initiate a constant with variable value?
by Corion (Patriarch) on Jun 04, 2010 at 14:05 UTC

    If you're worrying about whether loading a module costs time, then you're looking at the wrong locations:

    1. If your program runs a long time, then loading a module has a neglibile portion of the cost and optimizing that away gains you little opposed to the overall runtime of the program.
    2. If your program runs a short time but very often, then you should look at how to make your program run a longer time and process multiple requests. This will save you the loading and initialization time.
    3. If you're still worrying about the time that loading an external file might take, then Perl is the wrong approach.