in reply to Sort by string length
@sorted = sort { length $a <=> length $b } @elements
See also perldoc -q sort