use strict; my @words = ("one", "two", "three", "four", "sumofallnumbers", "five", "six", "seven", "eight"); my @sorted_words = sort {length($b) <=> length($a)} @words; print "the longest word is: $sorted_words[0]";