On Sat, Dec 27, 2008 at 11:04, Mr. Shawn H. Corey <shawnhco...@magma.ca> wrote:
snip
> Perl does not have true constants.  What `use constant` does is create a
> sub that returns the value.  That means you can use it as a sub in all
> your code.
snip

Just out of curiosity, what is your definition of a "true constant"?

Perl provides a better mechanism for constant scalars: the SvREADONLY
flag.  When this flag is set any attempt to modify the value of the
scalar throws a runtime error.  Accessing the SvREADONLY flag is a bit
hard, which is both a blessing and a curse; however, the Readonly
module* gives you the ability to set the flag, but not clear it (which
is a good thing).

* only if you have Readonly::XS installed, otherwise it uses a tied
variable that throws an error when STORE is called.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to