A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Sorting in Perl

Custom sorting method:

@sorted = sort { 
  if ($a eq 'aardvark') { return 1; }
  elsif ($b eq 'aardvark') { return -1; }
  else { return $a cmp $b; } 
} @words;

Remember to test for the special case for both $a and $b.


Thanks