#!/usr/bin/env perl
use strict;
use warnings;
use XML::XPath;
use Data::Dumper;
use List::Compare;
my @records;
my @eventrecords;
my $eventxml = 'events.xml';
my $evenxp = XML::XPath->new(filename => $eventxml);
my $evennodeset = $evenxp->findnodes('//event');
foreach my $evennode ($evennodeset->get_nodelist) {
my $evenssrid = $evenxp->find("./custom_attribute_list/custom_
+attribute[normalize-space(name)='SLB_SSRID']/value", $evennode);
s/^\s+|\s+$//g for $evenssrid;
push @eventrecords, {eventid => $evenssrid};
}
print Dumper \@eventrecords;
my $xml = 'ApplicationList.xml';
my $xp = XML::XPath->new(filename => $xml);
#my $nodeset = $xp->findnodes('//application_list');
for ($xp->findnodes('/application_list/application/@id') ) {
my $appid = $_->string_value;
$appid =~ s/^\s+|\s+$//g;
push @records, {appid => $appid};
}
print Dumper \@records;
#if ( scalar List::Compare->new(\@records, \@eventrecords)->get_in
+tersection ) {
# print "The arrays are the same";
#print Dumper @eventrecords;
#}
C:\SLB\Dashboard\Perl>perl testperl
$VAR1 = [
{
'eventid' => '957'
},
{
'eventid' => '2667'
},
];
$VAR1 = [
{
'appid' => '957'
},
{
'appid' => '975'
}
];
HOW TO GET ONLY ID PRESENT IN BOTH THE LIST AND NOT ALL THE RECORDS. |