You are really a monk saver for me ...!!!
Please do help me with 1more small query ... as per the code u shared yesterday i am getting eventid and name in diff arrays..
But Now i want out put as :
required output
$VAR1 = [
{
'eventid' => '957',
'name' => 'aaaa'
},
{
'eventid' => '2667',
'name' => 'bbbb'
},
{
'eventid' => '2667'
'name' => 'bbbb'
},
{
'eventid' => '1503'
'name' => 'cccc'
},
{
'eventid' => '1103'
'name' => 'dddd'
},
{
'eventid' => '1503'
'name' => 'cccc'
}
];
How can i do with multiple loop :
#!/usr/bin/env perl
use strict;
use warnings;
use XML::XPath;
use Data::Dumper;
my $xml = 'ApplicationList.xml';
my $xp = XML::XPath->new(filename => $xml);
my $appxpath = $xp->findnodes("//application_list/application/");
my %appid = ();
foreach my $appnodeset ($appxpath->get_nodelist) {
my $id = $xp->find('./@id',$appnodeset)->string_value;
my $name = $xp->find('./@name',$appnodeset)->string_value;
s/^\s+|\s+$//g for $id,$name;
$appid{$id} = $name;
}
print Dumper \%appid;
my $eventxml = 'events.xml';
my $evenxp = XML::XPath->new(filename => $eventxml);
my $xpath = "//event/custom_attribute_list/custom_attribute[normalize-
+space(name)='SLB_SSRID']/value";
my @eventrecords = ();
foreach my $node ($evenxp->findnodes($xpath)) {
my $ssrid = $node->string_value;
$ssrid =~ s/^\s+|\s+$//g ;
if ( exists $appid{$ssrid} ){
push @eventrecords,
{ eventid => $ssrid };
}
}
print Dumper \@eventrecords;
Thanks for helping .
|