In deep complex XML

S

sow

To professional geeks of perl.
I need to get values from complicated xml which is below:

$VAR1 = {
'report_params' => {
'customer_code' => 'name',
'customer_id' => '123',
'account_details' => [
{
'account_code' => 'account01',
'state_code' => 'DELETED',
'related_ani' => {
'state_code' =>
'DELETED',
'phone_number' =>
'123456',
'object_id' => '12',
'subscription' => [
{

'valid_to' => '2007-07-17T13:42:46',

'valid_from' => '2007-07-16T19:17:05',

'service_type_code' => 'VoIP',

'service_code' => 'serv01'
},
{

'valid_to' => '2007-07-18T12:15:16',

'session' => [

{

'currency_code' => 'QWE',

'duration' => '0',

'amount' => '0',
},

{

'currency_code' => 'QWE',

'duration' => '1313',

'amount' => '-1.75',
}
],

'valid_from' => '2007-07-17T13:43:23',

'service_type_code' => 'VoIP',

'service_code' => 'serv02'
},
{

'valid_to' => '2007-07-18T12:51:19',

'valid_from' => '2007-07-18T12:47:51',

'service_type_code' => 'VoIP',

'service_code' => 'serv03'
}
]
},
'created_date' => '2007-07-16T19:02:12'
},
{
'account_code' => 'account02',
'state_code' => 'ENABLED',
'related_ani' => {
'state_code' =>
'ENABLED',
'state_change_date' =>
'2007-07-18T12:56:33',
'phone_number' =>
'123456',
'object_id' => '13',
'subscription' => [
{

'session' => [

{

'currency_code' => 'QWE',

'duration' => '0',

'amount' => '0',
},

{

'currency_code' => 'QWE',

'duration' => '150',

'amount' => '-1.975',
},

{

'currency_code' => 'SEC',

'duration' => '101',

'amount' => '-101',
},

{

'currency_code' => 'SEC',

'duration' => '616',

'amount' => '-616',
}
],

'valid_from' => '2007-07-18T12:56:33',

'service_type_code' => 'VoIP',

'service_code' => 'serv04'
}
},
'created_date' => '2007-07-18T12:52:47'
}
],
};

and script in perl:

#!/usr/bin/perl
use XML::Simple;
$xml = new XML::Simple;
$data = $xml->XMLin($ARGV[0],
KeyAttr => {account_details => 'account_code',subscription =>
'service_code',session => 'currency_code'},
ForceArray => 1,
);

foreach $e (@{$data->{account_details}->{account02}->{related_ani}-
{subscription}->{serv04}->{session}->{QWE}})
{
printf "value %20s\n",$e->{amount};
}

and I've error:
Pseudo-hashes are deprecated at ./script line 9.
No such pseudo-hash field "account02" at ./billing2 line 9.

Please write any advice. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top