P
Pradeep Patra
Hi all,
I have a complex array reference. I want to search the
'name'="v1" and if it matches then search for "ctrs" and then 'C-data'
get the value of "success"?
$VAR1 = [
#0
{
'timestamp' => '1020929',
'inst' => [
#0
{
'A-data' => [
#0
{
'C' => [
#0
{
'B-data' => [
#0
{
'c-count' => '8',
'result' => 'complete'
}
]
}
],
'name' => 'v1',
'id' => 'v1',
'ctrs' => [
#0
{
'C-
data' => [
#0
{
'value' => '0',
'name' => 'success'
},
#1
{
'value' => '0',
'name' => 'error'
},
#2
{
'value' => '0',
'name' => 'percent'
},
#3
{
'value' => '0',
'name' => 'latency'
},
#4
{
'value' => '0',
'name' => 'total'
},
]
}
]
}
]
}
]
}
];
I am trying to retrieve as following But it doesn't work. Am I missing
anything in dereferencing I guess. A sample source code will help.
my $a = $VAR1[0]; ---> To get "inst"
my $b = $a->{'A-data'};
print "A is $a";
print "B is $b";
if ($b->{'name'} eq 'v1') {
print "PASS";
}
Is there a efficient way of searching this kind then it will be
useful?
Regards
Pradeep
I have a complex array reference. I want to search the
'name'="v1" and if it matches then search for "ctrs" and then 'C-data'
get the value of "success"?
$VAR1 = [
#0
{
'timestamp' => '1020929',
'inst' => [
#0
{
'A-data' => [
#0
{
'C' => [
#0
{
'B-data' => [
#0
{
'c-count' => '8',
'result' => 'complete'
}
]
}
],
'name' => 'v1',
'id' => 'v1',
'ctrs' => [
#0
{
'C-
data' => [
#0
{
'value' => '0',
'name' => 'success'
},
#1
{
'value' => '0',
'name' => 'error'
},
#2
{
'value' => '0',
'name' => 'percent'
},
#3
{
'value' => '0',
'name' => 'latency'
},
#4
{
'value' => '0',
'name' => 'total'
},
]
}
]
}
]
}
]
}
];
I am trying to retrieve as following But it doesn't work. Am I missing
anything in dereferencing I guess. A sample source code will help.
my $a = $VAR1[0]; ---> To get "inst"
my $b = $a->{'A-data'};
print "A is $a";
print "B is $b";
if ($b->{'name'} eq 'v1') {
print "PASS";
}
Is there a efficient way of searching this kind then it will be
useful?
Regards
Pradeep