in reply to
Seaching for text in string and comparing to xml, if not found print text
Maybe a bit late, but one has to sleep sometimes. Here is the Proper Way™, i.e. using a pull-parser to process the huge XML:
#!/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;