【Perl读书笔记】if语句和关系运算符

来源:互联网 发布:linux 串口驱动 编辑:程序博客网 时间:2024/06/06 03:12

读 《C程序员精通Perl》http://book.douban.com/subject/1232075/   2.4节 笔记


#!/usr/bin/perluse strict;use warnings;if ( "19" < "100") { #true 数字比较        print "19 < 100\n";}if ( "19" le "100") { #false 字符串比较        print "19 le 100\n";}if ("hello" eq "world") { #false 字符串比较        print  "hello eq world\n";}if ("able" == "baker") { #true 数字比较, 但发出告警        print  "able == baker\n";}


运行结果:

[root@localhost perl_practice]# ./cond.pl
19 < 100
Argument "world" isn't numeric in numeric eq (==) at ./cond.pl line 18.
Argument "hello" isn't numeric in numeric eq (==) at ./cond.pl line 18.
able == baker
[root@localhost perl_practice]#








原创粉丝点击