in reply to Comparing two files

You haven't printed out the strings you're trying to compare:

$_ = "Priority Kirkgate, PC7588\n"; @fields = split /,/, $_ ; print "PC string from NEW list: >>$fields[1]<<";

This code will have your PC code with a leading space, and the rest of your code won't match that.

Also, it's not really efficient to read through the $old_file for every comparison. I'd read new computers into a hash and then check while stepping through $old_file whether the computer is known or not:

use strict; my %new_pc; ... while (<IN1>) { chomp; $count_in++; @fields = split /,/, $_; $PC_NO = $fields[1]; $PC_NO =~ s/\s*//g; $new_pc{ $PC_NO } = 1; }; ... while (<IN2>) { chomp; if (/CN=(PC\d+)\.OU/) { my $pc = $1; if (exists $new_pc{ $pc }) { # $pc is old and new, hence has survived delete $new_pc{ $pc }; } else { # $pc is old but not new, hence has been removed }; } else { warn "Ignoring line >>$_<<"; }; }; # All PCs in %new are now really new: for my $pc (keys %new) { print "$pc is new\n"; };