in reply to Seeking the longest string in an array

my @data = qw/a mnk ab m b bc abcd cd bcd bd m nk /; my $prev = ''; @data = grep { substr($prev, 0, length) ne $_ and ($prev = $_,1) } reverse sort @data;

update: Whoops, I hought it was initial substrings. Thanks ikegami for pointing out my foolishosity!

Dave.

Replies are listed 'Best First'.
Re^2: Seeking the longest string in an array
by ikegami (Patriarch) on Dec 12, 2004 at 05:58 UTC
    Doesn't work. Gives
    nk, mnk, cd, bd, bcd, abcd
    instead of
    mnk, abcd, bd