Prakash wrote:
Hi,
This is a sample of the variable given by Data::Dumper
function.
This function gives me the dump of the xml file into the
variable $VAR1.
$VAR1 = {
'Sample' => [
{
'books' => {
'ID' => '1',
'author' => 'my name.P',
'cost' => '300',
'edition' => '2',
'volume' => '2',
},
'seller' => 'amazon.com',
'discont' => '10%',
'date' => '22-2-02'
},
{
'books' => {
'ID' => '2',
'author' => 'my name.S',
'cost' => '40',
'edition' => '2',
'volume' => '1',
},
'seller' => 'amazon.com',
'discont' => 'none',
'date' => '22-2-02'
},
{
'books' => {
'ID' => '1',
'author' => 'my name.P',
'cost' => '300',
'edition' => '2',
'volume' => '2',
},
'seller' => 'amazon.com',
'discont' => '10%',
'date' => '22-2-02'
}
]
};
Now my question is after getting the values, I have 3 books
in my hash. How do i find out how many books, (ie., child
level nodes for sample) by perl code.
Assuming that $ARG1 is really $hashref (and also a reference to a hash):
print scalar @{$hashref->{Sample}}, "\n";
--
,-/- __ _ _ $Bill Luebkert ICQ=162126130
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs