Jon, now I'm beginning to see the light. My problem with your suggestion:
$record = MARC::Record->new():
$field = MARC::Field->new('270','','',
                           a => $ADP,
                           b => $CTYP,
                           c => $STP);
$record->append_fields($field)

was that if, for instance, $CTYP hadn't been defined, I'd get an error here. 
Now that I'm thinking about your solution, I can make sure that $CTYP is 
defined (as empty) initially, then fill it conditionally if I have the data, 
then put them all in the MARC field, filled or not.

I think that this will work for me. Thank you, and Paul, for your help and 
advice.

-Kevin

>>> Jonathan Gorman <[EMAIL PROTECTED]> 08/03/05 02:27PM >>>
On Wed, 3 Aug 2005, KEVIN ZEMBOWER wrote:

>
> I think that what I would like to do is something like this:
> if ($ADP) {
>   my $madp = MARC::Field->new('270',' ', '4', a=>$ADP);
>   $marcrecord->append_fields($madp);
> }
>
> if ($CTPY)
>   my $mctpy = MARC::Field->new('270',' ', '4', b=>$CTPY);
>   $marcrecord->append_fields($mctpy);
> }
>

Well, one option is to follow what Paul sent to you earlier and don't 
bother to check for empty references.  Also check out the docs on 
MARC::Field.  You could always create the field and add the subfields 
later.

I should warn you I haven't used MARC::Record extensively, but when I have 
it's been pretty straight forward.


> I think that this would create two 270 fields, one with an 'a' subfield 
> and one with a 'b' subfield. Is this a problem in MARC records? Does 
> this imply that there are two separate, different addresses? Is this the 
> way it's supposed to be done? I thought that I had to create a single 
> 270 field, with the various subfields. Will this import okay into Koha?

Wow, lot of questions.  Most of them seem to be the aspects same one: can 
I have two fields of the same type?  Yes, if they are repeatable, but 
that's not what you want in this case.  You do need to create one single 
field, which is why the approach above won't work.  Create one field, then 
add subfields, or just add empty fields when creating it like Paul 
suggested.

(My apologies to Paul if I'm not applying his suggestion correctly)
So a quick example might be


$record = MARC::Record->new():
$field = MARC::Field->new('270','','',
                           a => $ADP,
                           b => $CTYP,
                           c => $STP);
$record->append_fields($field)

So if the variables are empty, it doesn't matter because it will just lead 
to an empty subfield, which Kola should ignore anyhow.  (I don't know if 
it does or not, but I suppose it doesn't hurt to try).

Jon Gorman

Reply via email to