Perl的除非unless语句由一个布尔表达式和一个或多个语句组成。
unless - 语法
Perl编程语言中的exclude语句的语法是-
unless(boolean_expression) { # statement(s) will execute if the given condition is false }
如果布尔表达式的输出为 false ,则将执行exclude语句中的代码块。
unless - 流程图
unless - 示例
#!/usr/local/bin/perl $a=20; # check the boolean condition using unless statement unless( $a < 20 ) { # if condition is false then print the following printf "a is not less than 20\n"; } print "value of a is : $a\n"; $a=""; # check the boolean condition using unless statement unless ( $a ) { # if condition is false then print the following printf "a has a false value\n"; } print "value of a is : $a\n";
首先,除非语句使用小于运算符(<),该运算符比较两个操作数,如果第一个操作数小于第二个操作数,则返回true,否则返回false。
a is not less than 20 value of a is : 20 a has a false value value of a is :
参考链接
https://www.learnfk.com/perl/perl-unless-statement.html
标签:语句,20,无涯,value,Perl,false,unless,condition From: https://blog.51cto.com/u_14033984/6966039