http://www.perlmonks.org?node_id=1008843


in reply to Perl allows you to change the definition of false to make it true. (And vice versa.)

This should please the comp.lang.c old timers:
use strict; use warnings; use 5.010; BEGIN { &Internals::SvREADONLY(\undef, 0); ${\undef} = "Demons are coming out of my nose!"; };
I wonder if you can redefine other read-only values? I could not get the following to work.
BEGIN { &Internals::SvREADONLY(\'blue', 0); ${\'blue'} = 'turtle'; &Internals::SvREADONLY(\5, 0); ${\5} = 5.000000000001; };
(I have no idea why you would want to do this apart from JAPH or intentional sabotage)
  • Comment on Re: Perl allows you to change the definition of false to make it true. (And vice versa.)
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Perl allows you to change the definition of false to make it true. (And vice versa.)
by tobyink (Canon) on Dec 14, 2012 at 15:14 UTC

    AFAIK, only true, false and undef. I thought perhaps "0 but true" might work (as that has special handling - it doesn't warn if used in numeric context) but no joy.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'