Skip Menu |

This queue is for tickets about the MARC-Record CPAN distribution.

Report information
The Basics
Id: 49847
Status: rejected
Priority: 0/
Queue: MARC-Record

People
Owner: Nobody in particular
Requestors: jacob.roche [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: problems with new field creation
Date: Sat, 19 Sep 2009 17:32:21 -0700
To: bug-MARC-Record [...] rt.cpan.org
From: Jacob Roche <jacob.roche [...] gmail.com>
Hi, I'm having some problems making new fields. Namely, I'm trying to build a 020 field, and it simply isn't working. I'll use a bit of code like: if ($MARC_page =~ m{ (?:020<)? # MARC code followed by a bracket to identify .*? # followed by anything \|a\s # followed by a pipe and the subfield (\d{13}) # followed by a 13-digit ISBN code }xmgs) { my $isbn = MARC::Field->new('020', 'a' => $1); } and I get the error: "Field 020 must have at least one subfield at getDavisRecord.pl line 75". I've tested and made sure that $1 is equal to a 13 digit ISBN code, so there's no issue there. And clearly I am giving field 020 at least one subfield. I've tried even copying your sample code (you used a 245 tag with two indicators, so I removed the indicators and changed it to 020) and it still gives me the error. I'm not sure how to convince it that it does in fact have a subfield. Any help would be much appreciated, and thank you for creating this module in the first place. Best regards, Jacob Roche
Hi, Although 020 has no use for the indicators, the new() sub still requires these to be passed in for fields which are not control fields. So, your code should look like: MARC::Field->new( '020', '', '', a => $1 ); Cheers, -Brian
Subject: Re: [rt.cpan.org #49847] problems with new field creation
Date: Sun, 4 Oct 2009 19:52:57 -0700
To: bug-MARC-Record [...] rt.cpan.org
From: Jacob Roche <jacob.roche [...] gmail.com>
Hi, thanks for getting back to me and explaining that. I'm still having some odd problems though. 1. It seems that when i set subfield a to $1, I have to double quote $1. So instead of MARC::Field->new( '020', '', '', a => $1 ); I actually have to do: MARC::Field->new( '020', '', '', a => "$1" ); I'm not sure why this is, as the double quotes just interpolate the variable so it's read as if I had done it without the quotes. 2. It's only working with certain fields/subfields. For example, I've used identical code to set the place of publication, 260a, but when I try to set publisher and publishing date, 260b and 260c, nothing happens. My guess is that the append_fields method doesn't act as an append_subfields method as well. That is, once I've set field 260 to have subfield a, but not set subfields b and c at the same time, I can no longer add any more subfields later. Is this correct? If so, how do I go about adding subfields later, as I do need to be able to do this. If this is not correct, can you please help me figure out why the extra subfields are not adding? Here's the sample code I'm working with: if ($MARC_page =~ m{ 260 .*? \|a\s (.*?) \| }xmgs) { $place_of_publication = MARC::Field->new('260',' ',' ', 'a' => "$1"); } else { $place_of_publication = MARC::Field->new( '260',' ',' ', 'a' => "no place of publication"); } $ucd_record->append_fields($place_of_publication); if ($MARC_page =~ m{ b\s (.*?) # followed by the title \| # followed by a pipe and the next subfield }ixmgs) { $publisher = MARC::Field->new('260','','', 'b' => "$1"); } else { $publisher = MARC::Field->new('260','','', 'b' => "no publisher"); } $ucd_record->append_fields($publisher); $place_of_publication works fine, but $publisher doesn't append. I have verified that $1 does have information in it, and even if the regex didn't work and $1 had nothing, "no publisher" should be set, so it is an issue with creation and appending of the field itself. Any help would be much appreciated. Thanks. Best regards, Jacob Roche On Mon, Sep 21, 2009 at 7:03 AM, Brian Cassidy via RT <bug-MARC-Record@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=49847 > > > Hi, > > Although 020 has no use for the indicators, the new() sub still requires > these to be passed in for fields which are not control fields. So, your > code should look like: > > MARC::Field->new( '020', '', '', a => $1 ); > > Cheers, > > -Brian >
This is turning into more of a usage question rather than an actual bug report. I am closing this ticket, and I'll reply to you directly.