MARC::Field->subfields function
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). Any thoughts are appreciated. Justin -- Justin Rittenhouse Systems Support Library Systems Department Hesburgh Libraries http://www.library.nd.edu/ (574) 631-3065
RE: MARC::Field->subfields function
On Wednesday, September 08, 2010 3:51 PM, Justin Rittenhouse [mailto:jritt...@nd.edu] 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 bryan.bal...@quality-books.com eij...@cpan.org http://home.comcast.net/~eijabb/
RE: MARC::Field->subfields function
Ahh...I bet that's it...and I see an "is control field" function which should allow me to skip those and only hit the fields that should have tags. That did it. Thanks! Justin -Original Message- From: Gorman, Jon [mailto:jtgor...@illinois.edu] Sent: Wednesday, September 08, 2010 4:58 PM To: Justin Rittenhouse; perl4lib@perl.org Subject: RE: MARC::Field->subfields function And what field are you pulling? Does it have subfields? Are you sure you're using the same variable? Seeing more of your code might make it easier to guess. Not all marc fields have to have subfields. Not sure what MARC::Field returns if it does not have any. If it returns undefined, that could probably cause problems if you're iterating over a record and there's a field without subfields. (Like the leader/fixed fields?). Others might have more ideas off the top of their head, but I figured I'd jot off a quick response just in case. Jon Gorman > -Original Message- > From: Justin Rittenhouse [mailto:jritt...@nd.edu] > Sent: Wednesday, September 08, 2010 3:51 PM > To: perl4lib@perl.org > Subject: MARC::Field->subfields function > > 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). > > Any thoughts are appreciated. > > Justin > -- > Justin Rittenhouse > Systems Support > Library Systems Department > Hesburgh Libraries > http://www.library.nd.edu/ > (574) 631-3065 >