当前位置: 首页 > news >正文

无涯教程-Perl - if...elsif...else语句函数

if 语句后可以跟可选的 elsif ... else 语句,这对于使用单个if ... elsif语句测试各种条件非常有用。

if...elsif...else - 语法

Perl编程语言中的 if ... elsif...else语句的语法是-

if(boolean_expression 1) {# Executes when the boolean expression 1 is true
} elsif( boolean_expression 2) {# Executes when the boolean expression 2 is true
} elsif( boolean_expression 3) {# Executes when the boolean expression 3 is true
} else {# Executes when the none of the above condition is true
}

if...elsif...else - 示例

#!/usr/local/bin/perl$a=100;
# check the boolean condition using if statement
if( $a  ==  20 ) {# if condition is true then print the followingprintf "a has a value which is 20\n";
} elsif( $a ==  30 ) {# if condition is true then print the followingprintf "a has a value which is 30\n";
} else {# if none of the above conditions is trueprintf "a has a value which is $a\n";
}

在这里,我们使用等于运算符==,用于检查两个操作数是否相等。如果两个操作数相同,则返回true,否则返回false。

a has a value which is 100

Perl 中的 if...elsif...else语句函数 - 无涯教程网无涯教程网提供if 语句后可以跟可选的 elsif ... else 语句,这对于使用单个if ... elsif 语句测试各...https://www.learnfk.com/perl/perl-if-elsif-statement.html

http://www.lryc.cn/news/111457.html

相关文章:

  • uniapp 实现滑动元素并下方有滚动条显示
  • QT充当客户端模拟浏览器等第三方客户端对https进行双向验证
  • 【JVM】 垃圾回收篇——自问自答(1)
  • Image Line FL Studio v21.0.3.3517 Producer版全插件版WIN免费下载完整版
  • PHP8条件控制语句-PHP8知识详解
  • 【PHP代码审计】ctfshow web入门 php特性 93-104
  • CSS元素的显示模式
  • Go strings.Title方法被废弃(Deprecated)
  • vuejs源码分析之全局API(vm.$off)
  • elasticSearch常见的面试题
  • 第一课-前提-Stable Diffusion 教程
  • Python 开发工具 Pycharm —— 使用技巧Lv.2
  • 代码随想录第39天 | 62. 不同路径、63.不同路径II
  • QMT入门—初识QMT
  • C 语言的 return 语句
  • 企业级Vue路由角色权限应该怎么做?
  • 3.2.0 版本预告!Apache DolphinScheduler API 增强相关功能
  • 测试工程师的工作
  • 压力测试与测试工具jmeter的介绍
  • 解析整型最大值(Integer.MIN_VALUE)溢出变为最小值(Integer.MAX_VALUE)
  • 【openpcdet】dbinfo内的信息
  • clickhouse查询缓存
  • vue中使用Base64加密、解密以及des加密、解密
  • 关于丢失安卓秘钥的撞sha-1值的办法
  • maven如何打包你会吗?
  • idea 控制台 打印 Tomcat日志Tomcat Catalina Log控制台乱码问题
  • python我的世界
  • SpringBoot+vue 大文件分片下载
  • scanf函数读取数据 清空缓冲区
  • js 文件常用转换