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.
update_field( $record, $fieldName, $subfieldName, $dont_erase, $value[, $value,[ $value ... ] ] ); Updates a field with the given value, creating it if neccessary. If multiple values are supplied, they will be used to update a list of repeatable fields until either the fields or the values are all used. If a single value is supplied for a repeated field, that value will be used to update each of the repeated fields.
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.
$bool = field_exists( $record, $fieldName[, $subfieldName ]); Returns true if the field exits, false otherwise.
$bool = field_equals( $record, $value, $fieldName[, $subfieldName[, $regex [, $n ] ] ]); 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' If $n is passed, the Nth field of a repeatable series will be used for comparison. Set $n to 1 or leave empty for a non-repeatable field.
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.