There's more than one way to do things | |
PerlMonks |
Re: The longest word ....by dingus (Friar) |
on Nov 12, 2002 at 07:24 UTC ( [id://212213]=note: print w/replies, xml ) | Need Help?? |
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: 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.
In Section
Seekers of Perl Wisdom
|
|