in reply to The longest word ....

Yet, my perl issue is that I really wonder what would be a shorter solution for my longest_words routine.

I think you want to do the hash the other way around. I.e. make it a hash of lengths and push each word onto an anonymous array of words of than length:

sub longest_words { my %W; push (@{$W{length($_)}}, $_) for (split /\s+/, join ' ', @_); return @{$W{ (sort{$b <=>$a} keys %W)[0]} }; }
Notes: If you do a print Dumper (\%W); before the return you will see the hash that has been constructed.
The (sort{$b <=>$a} keys %W)[0] returns the key with the highest numerical value.

Dingus


Enter any 47-digit prime number to continue.