Perl Monk, Perl Meditation PerlMonks

### Re: Perl allows you to change the definition of false to make it true. (And vice versa.)

 on Dec 14, 2012 at 14:26 UTC ( #1008843=note: print w/ replies, xml ) Need Help??

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.)
Re^2: Perl allows you to change the definition of false to make it true. (And vice versa.)
by tobyink (Abbot) 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'

Create A New User
Node Status?
node history
Node Type: note [id://1008843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-01-31 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?