Welcome to the Monastery | |
PerlMonks |
Re^2: Need clean codeby eyepopslikeamosquito (Archbishop) |
on Mar 25, 2017 at 23:17 UTC ( [id://1185963]=note: print w/replies, xml ) | Need Help?? |
For what it's worth, some of this applies equally in many languages such as C and C++. There's not really a concept of definedness in C/C++, but the concept of short circuiting in expressions using ||, and of ternary operators is nearly identical.But please be warned that the semantics of the || and && operators in C/C++ is significantly different to Perl. For example, this Perl code:
prints:
While this C++ code: prints: Why? Because in C/C++, the (short-circuiting) || and && operators always return 0 or 1. Unlike Perl, they do NOT return the last value evaluated. IMHO, this deliberate Perl change in semantics of these two venerable short-circuiting operators was a clever innovation from Larry, making them more convenient to use, notably when setting default values.
In Section
Seekers of Perl Wisdom
|
|