open(my $fh, "somefile.txt") or die("ack - $!"); my @lines = <$fh>; # let's hope this isn't a large file ... for (0 .. $#lines) { print "a change - $lines[$_]" if $lines[$_] ne $lines[$_ - 1]; }