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

Replies are listed 'Best First'.
Re^3: Perl allows you to change the definition of false to make it true. (And vice versa.)
by BrowserUk (Patriarch) 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 (Sage) 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