Paul, thank you so much for your reply. Looking at my example again, I see I've 
really botched it up. It should have been:
 
I have fields like these in my existing database:
ADP - Producer's address
CTYP - Producer's city
STP - Producer's state or province
etc.

Any or all of these could be missing.

I'd like to create a 270 field (I think) from this information. I'd like to do 
something similar to this pseudo-code:
my $mprod = MARC::Field->new('270', ' ', ' ',); #Base record
$mprod = MARC::Field->update($mprod, a=>$ADP) if $ADP;
$mprod = MARC::Field->update($mprod, b=>$CTYP) if $CTYP;
$mprod = MARC::Field->update($mprod, c=>$STP) if $STP;
....

In other words, I want to conditionally construct the subfields based on the 
available information in my existing DB.

My problem is that to construct a single 270 field, the number of 'if' clauses 
grows as the square of the variables. For instance, if I just have A or B:
if (A && B) do version 1
else if (A && ! B) do version 2
else if (B && ! A) do version 3
else do version 4

I'm not sure how I would apply your advice about empty values. 

Paul, thanks for your reply and your patience with me.

-Kevin

>>> Paul POULAIN <[EMAIL PROTECTED]> 08/03/05 12:39PM >>>
KEVIN ZEMBOWER a écrit :
> My ultimate goal is to import them into Koha to manage the collection.

good goal ;-)

> Can anyone help me out with a way of doing this efficiently? Thanks for your 
> advice and suggestions.

You should do this in 2 steps :
        my $newRecord = MARC::Record->new(); # 1st to create the record
        $newField = MARC::Field->new( # 2nd to create the field
                '011','','',
                'a' => $resul{ISSN},
        );
        # to happend the record to the field.
        $newRecord->insert_fields_ordered($newField);

If you have empty values, just say 'a' => "".$resul{ISSN}

(Perl dislike a lot hashes with empty values)

when you will bulkmarcimport your biblio in Koha, empty subfields will 
be ignored, so don't bother ;-)

HTH
-- 
Paul POULAIN
Consultant indépendant en logiciels libres
responsable francophone de koha (SIGB libre http://www.koha-fr.org)

Reply via email to