use strict;
use warnings;#数值比较大小和字符串比较大小 my $str1="1 -the first str"; my $str2="1 - the second str"; if($str1==$str2) { print "numerically equal\n"; } if($str1 eq $str2) { print "stringwise equal\n" ; } print "a.b"."haha"有用的测试样例:
use strict; use warnings; my $x= 1; if( $x) { print " x:yes\n "; } my $y= 0; if( $y) { print " y:yes\n "; } my $z= 0.0; if( $z) { print " z:yes\n "; } my $a= " 0 "; if( $a) { print " a:yes\n "; } my $b= ' 00 '; if( $b) { print " b:\yes\n " ; } my $c= " 0.0 "; if( $c) { print " c:yes\n "; } my $d= ""; if( $d) { print " d:yes\n "; } my $e= " "; if( $e) { print " e:yes\n " } my $g= " 0 "; if( $g== $c) { print " numerically equal " ; } if( $g eq $c) { print " string-wise equal "; }