O
Oliver Meister
Dear All
Unfortunately I haven't figured out how i can count the number of
values in the array "Exchange".
I was trying with $var = @arr, key and scalar syntax but also my
attempt try was not successful [2].
With this example [1], I am expecting to have a count of 3 for the Key
"Exchange".
May I ask for a helping hand?
Kind Regards
Oliver
[1]
$VAR1 = {
'InputList' => {
'InputListAction' => 'Replace',
'Instrument' => [
{
'Exchange' => 'SWX',
'Identifier' => '.SSHI',
'IdentifierType' =>
'RIC',
'Description' => 'SPI
TOTAL RETURN'
},
{
'Exchange' => 'N/E',
'Identifier' =>
'AUD6MFSR=',
'IdentifierType' =>
'RIC',
'Description' =>
'Australian Dollar 6 month LIBOR'
},
{
'Exchange' => 'N/E',
'Identifier' =>
'AUD7M=',
'IdentifierType' =>
'RIC',
'Description' =>
'Australian Dollar 7 month Forward'
},
{
'Exchange' => 'N/E',
'Identifier' => 'ZAR=',
'IdentifierType' =>
'RIC',
'Description' => 'South
African Rand Spot'
}
],
'Name' => ' TEST Import'
}
};
[2]
.....
$i = 0;
foreach $xChange (
$data->{'InputList'}->{'Instrument'}->['Exchange'] )
{
print $i;
.....
From an XML file, I have an array (hash) generated [1].
Unfortunately I haven't figured out how i can count the number of
values in the array "Exchange".
I was trying with $var = @arr, key and scalar syntax but also my
attempt try was not successful [2].
With this example [1], I am expecting to have a count of 3 for the Key
"Exchange".
May I ask for a helping hand?
Kind Regards
Oliver
[1]
$VAR1 = {
'InputList' => {
'InputListAction' => 'Replace',
'Instrument' => [
{
'Exchange' => 'SWX',
'Identifier' => '.SSHI',
'IdentifierType' =>
'RIC',
'Description' => 'SPI
TOTAL RETURN'
},
{
'Exchange' => 'N/E',
'Identifier' =>
'AUD6MFSR=',
'IdentifierType' =>
'RIC',
'Description' =>
'Australian Dollar 6 month LIBOR'
},
{
'Exchange' => 'N/E',
'Identifier' =>
'AUD7M=',
'IdentifierType' =>
'RIC',
'Description' =>
'Australian Dollar 7 month Forward'
},
{
'Exchange' => 'N/E',
'Identifier' => 'ZAR=',
'IdentifierType' =>
'RIC',
'Description' => 'South
African Rand Spot'
}
],
'Name' => ' TEST Import'
}
};
[2]
.....
$i = 0;
foreach $xChange (
$data->{'InputList'}->{'Instrument'}->['Exchange'] )
{
print $i;
.....