in reply to Crazy constant question...
Further to the suggestions of SilasTheMonk and thargas, an example. Note that numeric context must now be supplied explicitly. Also, I have no idea what this does to execution speed. Caveat Programmor.
c:\@Work\Perl>perl -wMstrict -le "use Scalar::Util qw(dualvar); use Readonly; Readonly my $foo => dualvar 42, 'FOO'; print qq{foo ($foo) = }, 0+$foo; $foo = '11'; print qq{after ro mod}; " foo (FOO) = 42 Modification of a read-only value attempted at -e line 1
(Read-only modification also fails with numeric assignment.)
|
|---|