【Perl讀書筆記】if語句和關係運算符

讀 《C程序員精通Perl》http://book.douban.com/subject/1232075/   2.4節 筆記


#!/usr/bin/perl
use 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]#








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章