in reply to Read file line by line and check equal lines

Something similar to this should do it. The trick is not to update $lastline until you don't have a match. As a side note, in the past I have successfully loaded around 100K lines into an array. You may be surprised at what Perl can handle.

open (IN, "$input_file"); open (OUT, ">$output_file"); my $lastline = <IN>; print OUT $lastline; while(<IN>){ my $line = $_; if ($line eq $lastline){ next; } print OUT $line; $lastline = $line; }

update: corrected typo