Perl中<=>(小于,等于,大于)的含义?

前端之家收集整理的这篇文章主要介绍了Perl中<=>(小于,等于,大于)的含义?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
this answer中,我看到了语法< =&gt ;;这是什么意思?它似乎是基于上下文的某种比较,但这是我可以收集的全部内容.部分背景:
sub rev_by_date { $b->[9] <=> $a->[9] }
my @sorted_files = sort rev_by_date @files;

解决方法

Perldoc开始:

Binary “<=>” returns -1,or 1 depending on whether the left argument is numerically less than,equal to,or greater than the right argument. If your platform supports NaNs (not-a-numbers) as numeric values,using them with “<=>” returns undef. NaN is not “<“,“==”,“>”,“<=” or “>=” anything (even NaN),so those 5 return false. NaN != NaN returns true,as does NaN != anything else. If your platform doesn’t support NaNs then NaN is just a string with numeric value 0.

原文链接:https://www.f2er.com/Perl/172026.html

猜你在找的Perl相关文章