my %seen; while (<>) { next if ($seen{$_}++); print; } #### my $last; while (<>) { next if ($_ eq $last); $last = $_; print; }