RE: MARC::Field->subfields function

[email protected] (Bryan Baldus)
Newsgroups perl.perl4lib
Message-ID <AE5353CC4A55324E832DA208826294ACA95F532707@QBIMAIL.qbi.quality-books.com>
On Wednesday, September 08, 2010 3:51 PM, Justin Rittenhouse [mailto:[email protected]] wrote:
>I'm relatively new to Perl and very new to the MARC::Record module.  I'm trying to use the subfields function (my @subfields = $field->subfields();), but I'm getting an error:
>Can't use an undefined value as an ARRAY reference at /usr/lib64/perl5/vendor_perl/5.8.8/MARC/Field.pm line 275.
>I'm not familiar enough with Perl to figure out what the function is actually doing, so I can't figure out if this is a bug or if I missed something in the tutorial.  Other functions off of the $field variable work (I can pull the tag, indicator, and as_string functions).

It's difficult to say what went wrong without a little more context. In MARC::Lint, to access the subfields of a field, the following code appears fairly frequently to break down the subfields into code+data pairs in an array:

#where $field is a MARC::Field object

my @subfields = $field->subfields();
my @newsubfields = ();

while (my $subfield = pop(@subfields)) {
    my ($code, $data) = @$subfield;
    unshift (@newsubfields, $code, $data);
} # while

###############

What does your code look like in the area that is producing the error?

Thank you,

Bryan Baldus
[email protected]
[email protected]
http://home.comcast.net/~eijabb/
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.