in reply to There is a way to LOCK a SCALAR?
The user? The user doesn't use Perl, the developer uses Perl.
Why do you want a scalar and not a sub?
Anyway, others have already suggested assigning a reference to a literal (a literal is a readonly scalar variable, really!) to a typeglob, but there is a way to turn the readonly flag on during runtime, using xmath's Spy module, which unfortunately he never finished.
Note that with Spy you can do evil things. Some variables are supposed to always be read-only. Like undef (${\undef}), true (${\!0}) and false (${\!1}). It's fun to make them writable, though, so feel free to experiment.use Spy; my $foo = 123; spy(\$foo)->readonly = 1; $foo++; # Modification of a read-only value attempted at - line 5.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: There is a way to LOCK a SCALAR?
by gmpassos (Priest) on Dec 18, 2003 at 20:40 UTC | |
|
Re: Re: There is a way to LOCK a SCALAR?
by gmpassos (Priest) on Dec 18, 2003 at 20:24 UTC | |
by Juerd (Abbot) on Dec 18, 2003 at 21:17 UTC | |
by gmpassos (Priest) on Dec 18, 2003 at 21:22 UTC |