RE: MARC::Field-subfields function

2010-09-09 Thread Gorman, Jon
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
 



Re: MARC::Field-subfields function

2010-09-09 Thread Galen Charlton
Hi,

On Thu, Sep 9, 2010 at 5:57 AM, Colin Campbell
colin.campb...@ptfs-europe.com wrote:
 On 08/09/10 22:07, Justin Rittenhouse wrote:
 Taking a look at MARC/Field.pm there's a bit of shaky error handling.
 subfields checks to see if its a control field, warns that it is then
 proceeds to try and return the non-existent array. It should just return
 at that point.

 I'll take a look at creating a patch for that.

I have applied this patch.  There aren't enough changes yet to do
another CPAN release of MARC::Record, but anybody who wants to use the
latest and greatest can always grab it from the Git repository:

git://marcpm.git.sourceforge.net/gitroot/marcpm/marcpm

Regards,

Galen
-- 
Galen Charlton
gmcha...@gmail.com


RE: MARC::Field-subfields function

2010-09-08 Thread Bryan Baldus
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/