On Sun, 21 May 2000 at 18:12:25 +0100, Mark Summerfield wrote: > Several people have developed independent solutions to readonly > variables which suggests to me that there is a requirement for them: > Andreas pointed out Graham Barr's tie-based solution at > http://www.xray.mpe.mpg.de/mailing-lists/modules/1999-02/msg00090.html > > Mark-Jason Dominus pointed out his tie-based solution at > http://www.plover.com/~mjd/perl/Locked/ > > I pointed out my (old) tie-based solution (on my perl antiques page). Hmm... I've always (well, since perl 5) done this: *pi = \3.14159; You can then read $pi, but not alter it. No XS, modules or tying required. ~ % perl -we '*pi=\3.14159;print "pi=$pi\n"; $pi+=1; print "pi now $pi\n";' pi=3.14159 Modification of a read-only value attempted at -e line 1. I just did a Benchmark and the speed of reading is identical with a "normal" global scalar. IanThread Previous | Thread Next