Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

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


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
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'

Log In?
Username:
Password:

What's my password?
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 scrutinizing the Monastery: (8)
As of 2014-12-28 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls