in reply to [perlre/perlgolf] Golf this: return -1 or return +1 on regexp subroutine please

sub by_priority { for (qw(Organization Service FAQ)){ $a=~/^$_/?return -1: $b=~/^$_/?return 1:1 } return $a cmp $b; }

fglock beat me to it. But same, idea different way to do it, and I think the same amount of strokes.

-enlil

  • Comment on Re: [perlre/perlgolf] Golf this: return -1 or return +1 on regexp subroutine please
  • Download Code