在
this answer中,我看到了语法< => ;;这是什么意思?它似乎是基于上下文的某种比较,但这是我可以收集的全部内容.部分背景:
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.