use Readonly; Readonly my $fortytwo => 42; # note: =>, not = ... if ($fortytwo=$answer) { # "Modification of a read-only value attempted" ... }