Quoted from perldoc:
Binary "==" returns true if the left argument is numerically equal to the right argument.
Binary "eq" returns true if the left argument is stringwise equal to the right argument.
实际上也就是说==返回是是否数值相等,而eq返回的是字符相等。
结果只有numerically equal。
PS:perl会自动转换字符串。$str1 == $str2中的值都是1
Binary "==" returns true if the left argument is numerically equal to the right argument.
Binary "eq" returns true if the left argument is stringwise equal to the right argument.
实际上也就是说==返回是是否数值相等,而eq返回的是字符相等。
-
Perl code
-
$str1 = " 1 -the first str " ; $str2 = " 1 -the second str " ; print " numerically equal\n " if ( $str1 == $str2 ); print " stringwise equal\n " if ( $str1 eq $str2 );
结果只有numerically equal。
PS:perl会自动转换字符串。$str1 == $str2中的值都是1
实际上也就是说==返回是是否数值相等,而eq返回的是字符相等