🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Perl 中的`if-else`语句 > 原文: [https://beginnersbook.com/2017/02/if-else-statement-in-perl/](https://beginnersbook.com/2017/02/if-else-statement-in-perl/) 在[上一篇教程](https://beginnersbook.com/2017/02/if-statement-in-perl/)中,我们了解了 perl 中的`if`语句。在本教程中,我们将了解`if-else`条件语句。这是`if-else`语句的外观: ```perl if(condition) { Statement(s); } else { Statement(s); } ``` 如果条件为真,则`if`内的语句将执行,如果条件为假,则`else`内的语句将执行。 #### 例: ```perl #!/usr/local/bin/perl printf "Enter any number:"; $num = <STDIN>; if( $num >100 ) { # This print statement would execute, # if the above condition is true printf "number is greater than 100\n"; } else { #This print statement would execute, #if the given condition is false printf "number is less than 100\n"; } ``` **输出:** ```perl Enter any number:120 number is greater than 100 ```