Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by tobyink (Abbot)
on Dec 12, 2012 at 20:38 UTC ( #1008583=note: print w/ replies, xml ) Need Help??


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

I discovered the trick perusing boolean which uses it to good effect. It makes boolean expressions such as "foo" eq "bar" return boolean objects (which in turn overload boolification). The net effect is to give Perl a boolean type.

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


Comment on Re^2: Perl allows you to change the definition of false to make it true. (And vice versa.)
Download Code
Re^3: Perl allows you to change the definition of false to make it true. (And vice versa.)
by BrowserUk (Pope) on Dec 12, 2012 at 22:09 UTC
    boolean which uses it to good effect. It makes boolean expressions such as "foo" eq "bar" return boolean objects

    Sounds like a great way to burn cycles for no good reason.

    All someone needs to do now is wrap boolean over in a Moose wrapper and we can all compute like it was 1984 :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

Re^3: Perl allows you to change the definition of false to make it true. (And vice versa.) (boolean.pm)
by tye (Cardinal) on Dec 12, 2012 at 22:39 UTC
    do &maybe if boolean($value)->isTrue;

    Surely he meant:

    do &maybe if boolean( true eq boolean($value)->isTrue() )->isTrue();

    (:

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-10-25 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls