use warnings; use strict; my @first_list; my @second_list; my %first_lc; my @second_lc; open FIRST_LIST, "< first_list.txt" or print $! "\n"; @first_list=; close (FIRST_LIST); chomp (@first_list); open SECOND_LIST, "< second_list.txt" or print $! "\n"; @second_list=; close (SECOND_LIST); chomp (@second_list); # create look up of machines in lower case my %first_lc = map { lc => 1 } @first_list; # not stricty necessary could use map in loop my @second_lc = map { lc } @second_list; print "Machines extra in second list\n\n"; foreach my $unique (@second_lc) { if (exists $first_lc{$unique}) { print "already there $unique\n\n"; } else { print "newly in this $unique\n\n"; } }