rsFalse has asked for the wisdom of the Perl Monks concerning the following question:
Output:#!/usr/bin/perl -l use strict; use warnings; push @_, $_ xor print $_ for 'a' .. 'b'; print @_;
Today I found (for myself) that 'xor' doesn't work in the same way as 'or' and 'and' do, and it is strange for me, why. It seems that, 'xor' not only evaluates one or both expressions surrounding it, but also evaluates logical XOR of these expressions, when 'or' and 'and' operators don't do this, i.e.:Useless use of logical xor in void context at ./perlmonks_xor_vs_or_an +d.pl line 6. a b ab
Output:#!/usr/bin/perl -l use strict; use warnings; print "[$_]" for ( 2 and 3 ), ( 2 or 3 ), ( 2 xor 3 ), ;
At the last line of output I expected to get '3'![3] [2] []
|
|---|