Hi Monks
I'm an ex-C-programmer who finds he has to write just one more program before senior citizenship intervenes. The program must be in Perl (which had only just been invented when I gave it up programming 15 years ago) and will eventually be maintained/extended by other people.
First the good news: programming is like riding a bicycle -- once you have learnt, you won't fall off; Perl is easy. The bad news is that Perl apparently has no equivalent of the C 'const' statement. Constants have to put in variables, which makes the program vulnerable to side-effects unless the programmer can guarantee that the variable can never be assigned a new value, now or in the future, or in the hands of any other person who might pick up the program.
The most common workaround seems to be the "use constant" pragma, which (I think) returns the const value from a sub. However, "use constant" has scoping problems -- can't use it.
What does work for me is Readonly, but the author warns that it is slow.
Two questions:
In reply to Module Readonly by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |