|The stupid question is the question not asked|
What is the difference between the constant construct in Perl and the Readonly construct in Perl?by jira0004 (Monk)
|on Jul 06, 2006 at 00:48 UTC||Need Help??|
jira0004 has asked for the
wisdom of the Perl Monks concerning the following question:
Perl provides two different constructs to allow a developer to set up a symbol for a value that will be used through out a package, but will not change; these two different constructs are constant and Readonly. Once a constant or a Readonly symbol is defined in a Perl package, it can not be changed else where in the package although it can be used as many times as the developer wishes.
Thus, in Perl there are two standard ways I could define a constant of PI (to six decimal places of accuracy) in my Perl program:
use constant PI => 3.141593;
use Readonly PI => 3.141593;
After using either constant or Readonly to define PI in my program, I can use it as a symbol in my program over and over again, although as the terms imply, I can not change its value.
Here is what I want to know: