Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Perl logical operators

by choroba (Cardinal)
on Jul 18, 2018 at 06:47 UTC ( [id://1218718]=note: print w/replies, xml ) Need Help??


in reply to Perl logical operators

true and false are barewords with no special meaning in Perl.

Moreover, you should use strict: it would have told you

Bareword "false" not allowed while "strict subs" in use at - line 1. Bareword "true" not allowed while "strict subs" in use at - line 2.

The common value used for true is 1, for false, you can use 0, "" or undef.

Also, $a and $b are special variables used in sort, it's better not to use them anywhere else.

#!/usr/bin/perl use warnings; use strict; my $A = 0; my $B = 1; print "Value of \$A = $A and value of \$B = $B\n"; my $c = ($A and $B); print "Value of \$A and \$B = $c\n"; $c = ($A && $B); print "Value of \$A && \$B = $c\n"; $c = ($A or $B); print "Value of \$A or \$B = $c\n"; $c = ($A || $B); print "Value of \$A || \$B = $c\n"; $A = 0; $c = not($A); print "Value of not(\$A)= $c\n";

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found