in reply to The longest word ....
A little shorter maybe and doesn't require any modules...
sub longest_words { my @W = $_[0] =~ /\b(\w+)\b/g; my $L = 0; $L = length() < $L ? $L : length for @W; grep length == $L, @W; }
I wouldn't actually do it this way though. I'd pay more attention to doing it in a single pass through the list of words.
Update: Switched back to the regex for extracting the words.
-sauoq "My two cents aren't worth a dime.";
|
|---|