Here is an example. For some strange reason, Perl thinks 1 and 0 are the true value. Why?
1 and 0
$ perl -e '$x = 1 and 0; print $x;' 1
Since the priority of and and && is different:
and
&&
$x = 1 and 0 is similar to ($x = 1) and 0 , while $x = 1 && 0 is similar to $x = (1 && 0) .
$x = 1 and 0
($x = 1) and 0
$x = 1 && 0
$x = (1 && 0)
See perlop (1) .
In your example, operator priority
perl -e '($x = 1) and 0; print $x;'
while you want:
perl -e '$x = (1 and 0); print $x;'
or
perl -e '$x = 1 && 0; print $x;'
No:
$ perl -e '$x = (1 and 0); print $x;' 0
Source: https://habr.com/ru/post/955803/More articles:Failed to authenticate package: 721772200.itmsp - iosHow to not save data in my reduce () function in MongoDB? - mongodbFailed to authenticate package: 727047181.itmsp - iosNetworkInfo.isConnected () returns true, but no connection - javaAny opportunity to use classes without QObject with QML - c ++Bash wait for the process to begin - bashGoogle calendar v3 returns 403 Not enough permission - ruby-on-railsIMEI / 01 Code - androidEasy way to fake freely defined Python recorder objects - pythongstreamer: How to do streaming through TLS? - sslAll Articles