in reply to How to group identical words?

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

On the other hand, if you're trying to remove duplicates, the answer is in perlfaq4.