How to get scalar context of a list within a complex array
[email protected] ("Christopher Morgan")
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <4945906990EA4FEC91BD383C09430986@DellMain> |
I have a complex array containing references to hashes. Some of the hash
keys point to anonymous lists. A typical element from this array looks like
this:
{
'_is_control_field' => '',
'_ind2' => '0',
'_subfields' => [
'a',
'Japanese paper folding'
],
'_warnings' => [],
'_tag' => 450,
'_ind1' => ' '
};
Since this is the first array element, to access the second item in the list
that "_subfields" points to, I use this syntax:
$fields[0] {'_subfields'}->[1];
This returns 'Japanese paper folding.'
This list can vary in size from element to element, so I would like a way to
refer to the list in scalar context to get its size. How do I do that?
(My current approach is to simply iterate through the list, pushing the
elements onto another array until I reach "undefined".)
Many thanks!
- Chris Morgan