my @lines=(); open (FILE,"$tempfile5") || die "Cannot read from $tempfile5\n"; my $found = 0; while(){ my $line_holder = $_; #DOH, should have had this here foreach my $val(@lines){ if($val eq $line_holder){$found = 1;} } if($found){ $found = 0; next; }else{ push @lines, $line_holder; } }