59 附加的控制流结构IV--&& || and ?
(Llama书的第九章)
thatcommand if thiscondition;#等价于
thiscondition && thatcommand;
因为如果PERL发现假的条件,将不继续&&(逻辑与).所以如果thiscondition为假, 不执行thatcommand.
类似地:
thatcommand unless thiscondition; #等价于
thiscondition || thatcommand;
注意能使用并替代&&或||
非(!)和异或(^)也允许.
我们能使用象C中的表达式.
expression ? Trudcalc : Falsecalc; #其等价于
if (expression) {Truecalc:} else {falsecalc;}
Copyright: NPACT