SimpleMARC - Perl module for making simple MARC record alterations.
use SimpleMARC;
SimpleMARC is designed to make writing scripts to modify MARC records simple and easy.
Every function in the modules requires a MARC::Record object as its first parameter.
Kyle Hall <lt>kyle.m.hall@gmail.com<gt>
Copyright (C) 2009 by Kyle Hall
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.
copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName[, $regex[, $n ] ] ); Copies a value from one field to another. If a regular expression ( $regex ) is supplied, the value will be transformed by the given regex before being copied into the new field. Example: $regex = { search => 'Old Text', replace => 'Replacement Text', modifiers => 'g' }; If $n is passed, copy_field will only copy the Nth field of the list of fields. E.g. $n = 1 will only use the first field's value, $n = 2 will use only the 2nd field's value.
add_field({ record => $record, field => $fieldName, subfield => $subfieldName, values => \@values, field_numbers => $field_numbers, }); Adds a new field/subfield with supplied value(s). This function always add a new field as opposed to 'update_field' which will either update if field exists and add if it does not.
my @values = read_field( $record, $fieldName[, $subfieldName, [, $n ] ] ); Returns an array of field values for the given field and subfield If $n is given, it will return only the $nth value of the array. E.g. If $n = 1, it return the 1st value, if $n = 3, it will return the 3rd value.
@field_numbers = field_exists( $record, $fieldName[, $subfieldName ]); Returns the field numbers or an empty array.
$bool = field_equals( $record, $value, $fieldName[, $subfieldName[, $regex ] ]); Returns true if the field equals the given value, false otherwise. If a regular expression ( $regex ) is supplied, the value will be compared using the given regex. Example: $regex = 'sought_text'
move_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName[, $regex [, $n ] ] ); Moves a value from one field to another. If a regular expression ( $regex ) is supplied, the value will be transformed by the given regex before being moved into the new field. Example: $regex = 's/Old Text/Replacement Text/' If $n is passed, only the Nth field will be moved. $n = 1 will move the first repeatable field, $n = 3 will move the third.
_delete_field( $record, $fieldName[, $subfieldName [, $n ] ] ); Deletes the given field. If $n is passed, only the Nth field will be deleted. $n = 1 will delete the first repeatable field, $n = 3 will delete the third.
update_last_transaction_time( { record => $record } ); Inserts or updates field for last transaction (005)