Next | Trivial Utilities | 68 |
sub comparator { my @F = @field{$a, $b}; my @re_count; for my $i (0 .. 1) { for ($F[$i]) { $re_count[$i]++ while s/^re:\s*//i; tr/A-Za-z/a-za-z/; tr/a-z//cd; } } $REVERSE * (lc $F[0] cmp lc $F[1] || $re_count[0] <=> $re_count[1] || $field{$a} cmp $field{$b} ); }
Tricks here:
The for ($x) topicalization idiom
$REVERSE * -- recall that $REVERSE is either +1 or -1
Next | Menu | Copyright © 2012 M. J. Dominus |