in reply to Remove Duplicate Lines

for(@sd){ push @out, $_ if (not @out) or ($out[-1] ne $_); };

update: added (not @out) to initialize array

Replies are listed 'Best First'.
Re^2: Remove Duplicate Lines
by Aristotle (Chancellor) on Sep 18, 2002 at 19:38 UTC
    @out = grep $sd[$_] ne $sd[1+$_], 0 .. $#sd; With inline sort and a perverse twist:
    my $prev; @out = grep "$prev" ne ($prev = $_), sort @sd; # not for production co +de

    Makeshifts last the longest.