Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Re: Anyone use "xor" in conditionals?

by sauoq (Abbot)
on Jul 14, 2003 at 17:05 UTC ( #274050=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Anyone use "xor" in conditionals?
in thread Anyone use "xor" in conditionals?

This way the conditions are evaluated less times

Eh? Not so.

$ perl -le 'print "T" if (print "foo" xor print "bar")' foo bar $ perl -le 'print "T" if ((print "foo" and not print "bar") or (not pr +int "foo" and print "bar"))' foo bar foo
At best, the expanded version will result in the same number of evaluations.

-sauoq
"My two cents aren't worth a dime.";


Comment on Re: Re: Re: Anyone use "xor" in conditionals?
Download Code
Replies are listed 'Best First'.
Re: Re: Re: Re: Anyone use "xor" in conditionals?
by Excalibor (Monk) on Jul 14, 2003 at 19:08 UTC

    Hi there,

    I was, of course, talking about the first extended version offered by Abigail:

    $ perl -le 'print "T" if ((print "foo" or print "bar") and (not (prin +t "foo" and print "bar"))' foo foo bar

    More specifically, I was talking in the case A is false (messier to write with print() as a one liner, left as an exercise for the reader :-)

    The point is, once you got the better, downlevel operator, use it if you need it! But no more than that.

    best regards,

    --
    our $Perl6 is Fantastic;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2015-07-31 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (281 votes), past polls