my $prev; while (<>) { next if ($_ eq $prev); print $prev = $_; }