General

Using arrays instead of hashes in MARC::Field constructor

Whenever you’re creating a MARC field using Perl’s excelent MARC::Field module, you can always use an array instead of a hash in order to specify subfield/data pairs. This is useful since some field/subfield combinations in MARC are repeatable, and the POD leads you to writing hashes for storing subfield/data pairs before creating the field. For example, the POD says:

my $field = MARC::Field->new(     245, '1', '0',     'a' => 'Raccoons and ripe co / ',     'c' => 'Jim Aosky.');

But this is also valid and works:

my @array = ('a', 'Raccoons and ripe co /', 'c', 'Jim Aosky.', 'k', 'typescript, 'k', 'diaries');my $field = MARC::Field->new ( 245 , '1', '0', @array );
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s