Grouped Duplicate Checking
If you just want to check for duplicates which are grouped together, that's easy. You can just check if the current line is the same as the last line:
my $line;
while(<$ifh>) {
next if (defined $line && $line eq $_);
$line = $_;
...
All Duplicate Checking
If you want to check for all duplicate lines in the file, regardless of their positioning, you'll have to do something like this:
my %seen;
while (<$ifh>) {
next if exists $seen{$_};
$seen{$_} = 1;
...
This won't be fast on a large file as hash lookups are pretty poor, but it's the best option if you don't want to modify the source file.