Re: How to get scalar context of a list within a complex array

[email protected] (Brad Baxter)
Newsgroups perl.beginners
Organization http://groups.google.com
Message-ID <[email protected]>
On Jun 12, 9:37 am, [email protected] (Christopher Morgan) wrote:
> 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

It looks like you have a MARC::Field object.  Have you studied the
docs
for MARC::Record? (http://search.cpan.org/dist/MARC-Record/)

--
Brad
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.