I have written a lot of code, probably not even a fraction of what experienced programmers have written, but quite a lot for my age i'd say (for I'm student and yet looking forward to studying CS and stuff).

Second, I really like playing around with the logical operators and short-circuit. That sometimes ends up in long but single statements.

my ($id,$pass,$user,$cookie); ( ( $id = $cgi->param( config('username_param') ) ) and ( $pass = $cgi->param( config('userpass_param') ) and $pass = crypt( $pass, $id ) ) ) or ( $cookie = do { require CGI::Cookie; my %c = CGI::Cookie->fetch; $c{ config('user_cookie') } } and ($id,$pass) = $cookie->value() ) or ($id,$pass) = (config('anonymous_name'),config('anonymous_pass'));

As you can guess and see from the example, the code i write is primarily for CGI stuff or short system-administration programs, rather pragmatic and often used only once. But the range of tasks is fairly broad.

But to the point: I have encountered many situations where "logical operator fun" can be used, but i have never used (it was never possible) the logical eclusive or.

Searching on this site gives me nodes that deal with XOR encryption, none deales with the 'xor' Operator.

Now, what i'd be interested in is: In what situations does the 'xor' come into play? I could imagine that scientific algorithms need it, but have you ever needed it in application code? My assumption that it seems to be "unused apart from demonstration of its functionailty" is strengthened by the fact that there seems to be only the bitwise XOR in C, no logical.

I'd really like to see snippets or explanations where the real-life use of Locigal Exclusive Or can be found or if it is just there for completeness.

--
http://fruiture.de

In reply to logical Exclusive Or, xor by fruiture

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.