Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
和 Java 中的 ()实现相同功能的 Perl 函数是什么compareTo?我知道eq但ne我想比较一下一个字符串是否大于另一个字符串。
compareTo
eq
ne
您实际上有cmp(对于字符串)和<=>(对于数字)运算符。请参阅perlop 中的相等运算符部分。
cmp
<=>
例子:
print "foo" cmp "bar"; # prints 1
gt应该做的伎俩
gt
编辑:实际上,cmp会更类似于 compareTo(),gt只会告诉你字符串是否大于另一个。