I read some data from an xml file into a hash.
Now the hash can be
$VAR1 = {
'XYZ' => [
{
'NAME' => 'N1'
},
{
'NAME' => 'N2'
}
],
};
OR Even
$VAR1 = {
'XYZ' => {
'NAME' => 'N1'
}
};
Meaning XYZ can be an 'Array of hashes' or a 'Single Hash'
Now if I want to traverse all that is contained in XYZ I first read the array length and then traverse it one by one.
To read array length:
my $array_length = scalar ( @{$Ref_to_hash_var->{XYZ}} );
This works fine till I have and 'Array of hashes' but gives me the error:
"Not an ARRAY reference at example.pl line 28."
How can I get a length of an array and in case its not an array I can know its length is zero.
Kindly suggest.
TIA
--
Apurva Shukla
---------------------
dream & dare
---------------------
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
