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' }
In reply to Re: There is a way to LOCK a SCALAR?
by Juerd
in thread There is a way to LOCK a SCALAR?
by gmpassos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |