use Spy; my $foo = 123; spy(\$foo)->readonly = 1; $foo++; # Modification of a read-only value attempted at - line 5.