3 ms·
I think I'd prefer populating %c using: $c{lc $_}++ for map split(), <ARGV>; (I pondered 'do { local $/; <ARGV> }' to do a full slurp as well, but I don't t
by mst 5y ago
I think I'd prefer populating %c using:
$c{lc $_}++ for map split(), <ARGV>;
(I pondered 'do { local $/; <ARGV> }' to do a full slurp as well, but I don't think it helps with clarity and I'm not actually golfing here even though the resulting code happens to be shorter)
Also, if you have List::UtilsBy handy (which I basically always do),
rev_nsort_by { $c{$_} } keys %c
could be a nicer way to express the sort, although probably as fast because of the block expr versus anon-sub-via-& prototype part.
(I have not executed any of this code, I'm just musing here, so no warranty express or implied ;)