in reply to How can I declare constants?

If you don't mind that it can be changed, you can simply declare your constants as follows:

# Constants used throughout the program: my $number_of_pages = 3;

If you are really paranoid and don't want your constants to be changeable, use the constant pragma:

use constant NUMBER_OF_PAGES => 3;

Replies are listed 'Best First'.
Re^2: How can I declare constants?
by Anonymous Monk on Oct 05, 2005 at 11:25 UTC
    Thank you. I used this pragma already but had the problems mentioned in the bugs section (brewordsm, sub calls). Does there exist any other alternative (no my or our declaration)?
      You can decalare a sub routine...
      use strict; use warnings; sub PI () {3.14} print PI;
      still not sure what you've got against 'my' though
      ---
      my name's not Keith, and I'm not reasonable.

      No. The only bareword-"problem" in the documentation also has a solution mentioned with it. Did you try that solution? What part of that solution did not work for you? Can you show some code that demonstrates how you followed the documentation but still got the wrong behaviour?

A reply falls below the community's threshold of quality. You may see it by logging in.