while (<>) { chomp; next if defined($last) && $_ eq $last; $last = $_; print; }