in reply to Seeking the longest string in an array
I think you'll find that this method easily beats any other in both processing speed and coding efficiency.use strict; use warnings; my @data = qw/a mnk ab m b bc abcd cd bcd bd m nk/; (my $result, @data) = sort {length($b) <=> length($a)} @data; for (@data) { $result .= ' '.$_ if index($result, $_) == -1; } print $result;
|
|---|