#!/usr/bin/perl use warnings; use strict; use XML::LibXML::Reader; open my $TXT, '<', '1.txt' or die $!; my %ids; while (<$TXT>) { undef $ids{ (split /,/)[5] }; } close $TXT; my $xml = XML::LibXML::Reader->new( location => '1.xml' ) or die "Cannot open xml\n"; while ($xml->nextElement('ALERT_ID')) { $xml->read; # Go to the text value. my $id = $xml->value; if (exists $ids{$id}) { delete $ids{$id}; } else { warn "Not found in csv: $id\n"; } } print "$_\n" for keys %ids;