use strict; use XML::Rules; use Data::Dumper qw(Dumper); my $parser = XML::Rules->new( stripspaces => 15, rules => { 'name,value' => 'content', statistic => sub { return '%' . $_[1]->{type} => { $_[1]->{name} => $_[1]->{value}} }, resourceGroup => 'no content array', statRecord => sub { #print Dumper($_[1]); foreach my $group (@{$_[1]->{resourceGroup}}) { print "$_[1]->{time}|$group->{name}|$group->{Lifetime}{LCONNFAIL}|$group->{Lifetime}{LLOSTCONN}|$group->{Lifetime}{LIDLETIMEOUT}|$group->{Startup}{SIPADDR}|$group->{Startup}{SIPPORT}\n"; } return; } } ); print "time|resourceGroup name|LCONNFAIL|LLOSTCONN|LIDLETIMEOUT|SIPADDR|SIPPORT\n"; $parser->parse(\*DATA); __DATA__ ...