$prev = 'nonesuch'; @out = grep($_ ne $prev && ($prev = $_), @in);
This is nice in that it doesn't use much extra memory, simulating
uniq's
behavior of removing only adjacent duplicates.
undef %saw; @out = grep(!$saw{$_}++, @in);
@out = grep(!$saw[$_]++, @in);
undef %saw; @saw{@in} = (); @out = sort keys %saw; # remove sort if undesired
undef @ary; @ary[@in] = @in; @out = sort @ary;