open in,"file" or die "can not open input file\n"; while (){ print if ($_ ne $prev_record); $prev_record = $_; }