Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module Readonly
by hardburn (Abbot) on Apr 23, 2004 at 13:11 UTC | |
|
Re: Module Readonly
by mutated (Monk) on Apr 23, 2004 at 13:12 UTC | |
|
Re: Module Readonly
by calin (Deacon) on Apr 23, 2004 at 16:23 UTC | |
|
Re: Module Readonly
by Tomte (Priest) on Apr 23, 2004 at 13:06 UTC | |
by hardburn (Abbot) on Apr 23, 2004 at 13:16 UTC | |
by Anonymous Monk on Apr 23, 2004 at 14:53 UTC | |
by ysth (Canon) on Apr 23, 2004 at 18:29 UTC | |
|
Re: Module Readonly
by Zaxo (Archbishop) on Apr 24, 2004 at 04:05 UTC | |
|
Re: Module Readonly
by pizza_milkshake (Monk) on Apr 23, 2004 at 15:11 UTC | |
|
Re: Module Readonly ( *foo = \'bar' )
by Anonymous Monk on May 30, 2013 at 07:23 UTC |