in reply to Condensing a grep into a sort
What you might want to do is a Schwartzian Transform so that the regex doesn't need to be applied to $a and $b repeatedly.
Hoping for partial credit, I eliminated the join.print map {"$_->[0]\n"} sort {$a->[1] <=> $b->[1]} map { [$_, (/C(\d*)/)[0]] } grep { /P/} @compounds;
|
---|