in reply to There is a way to LOCK a SCALAR?
Did you check CPAN for a module? If there isn't one, you could write one yourself to use the tie mechanism to subvert changing the value of the scalar. perldoc perltie
Here's a quick implementation (untested):
#!/usr/bin/perl package ConstScalar; sub TIESCALAR { my $class = shift; my $val = shift; return bless \$val, $class } sub STORE { } sub FETCH { my $self = shift; return $$self; } package main; my $pi; tie $pi, 'ConstScalar', 3.14159265358979323846; print "$pi\n"; $pi = 5; # no effect print "$pi\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: There is a way to LOCK a SCALAR?
by gmpassos (Priest) on Dec 18, 2003 at 20:20 UTC | |
by BUU (Prior) on Dec 18, 2003 at 21:20 UTC | |
by gmpassos (Priest) on Dec 18, 2003 at 21:29 UTC | |
by duff (Parson) on Dec 19, 2003 at 01:42 UTC | |
by BUU (Prior) on Dec 18, 2003 at 22:29 UTC |