use Inline C; my $FOO = "Bar"; readonly($FOO); $FOO = "GG"; __DATA__ __C__ void readonly(SV *sv) { SvREADONLY_on(sv); }