MARC
view release on metacpan or search on metacpan
# data for a first match, using the template, and leaves the rest
# alone. If the template has a subfield element, (this includes
# indicators) it ignores all other information in the array and only
# updates/creates based on the subfield information in the array. If
# the template has no subfield information then indicators are left
# untouched unless a new field needs to be created, in which case they
# are left blank.
####################################################################
sub updatefirst { # rec
my $marc = shift || return;
my $template = shift;
return unless (ref($template) eq "HASH");
return unless (@_);
return if (defined $template->{'value'});
my $recnum = $template->{'record'};
if (!$recnum) {mycarp "Need a record to confine my changing needs."; return undef}
return $marc->[$recnum]->updatefirst($template,@_);
}
####################################################################
# updatefields() takes a template which specifies recnum, a
# $do_rebuild_map and a field (needs the field in case $rafields->[0]
# is empty). It also takes a ref to an array of fieldrefs formatted
# like the output of getfields(), and replaces/creates the field
# data. It assumes that it should remove the fields with the first tag
# in the fieldrefs. It calls rebuild_map() if $do_rebuild_map.
####################################################################
sub updatefields { # rec
my $marc = shift || return;
my $template = shift;
my $rafieldrefs = shift;
my $recnum = $template->{'record'};
return $marc->[$recnum]->updatefields($template,$rafieldrefs);
}
####################################################################
return $marc->[0]{proto_rec}->insertpos(@_);
}
####################################################################
# updaterecord() takes an array of key/value pairs, formatted like #
# the output of getupdate(), and replaces/creates the field data. #
# For repeated tags, a "\036" element is used to delimit data into #
# separate addfield() commands. #
####################################################################
sub updaterecord {
my $marc = shift || return;
my $template = shift;
return unless (ref($template) eq "HASH");
return unless (@_);
return if (defined $template->{'value'});
my $count = 0;
my @records = ();
unless ($marc->deletemarc($template)) {mycarp "not deleted\n"; return;}
foreach my $y1 (@_) {
unless ($y1 eq "\036") {
# data for a first match, using the template, and leaves the rest
# alone. If the template has a subfield element, (this includes
# indicators) it ignores all other information in the array and only
# updates/creates based on the subfield information in the array. If
# the template has no subfield information then indicators are left
# untouched unless a new field needs to be created, in which case they
# are left blank.
####################################################################
sub updatefirst { # rec
my $marcrec = shift || return;
my $template = shift;
return unless (ref($template) eq "HASH");
return unless (@_);
return if (defined $template->{'value'});
my @ufield = @_;
my $field = $template->{'field'};
my $subfield = $template->{'subfield'};
####################################################################
# updatefields() takes a template which specifies a
# $do_rebuild_map and a field (needs the field in case $rafields->[0]
# is empty). It also takes a ref to an array of fieldrefs formatted
# like the output of getfields(), and replaces/creates the field
# data. It assumes that it should remove the fields with the first tag
# in the fieldrefs. It calls rebuild_map() if $do_rebuild_map.
####################################################################
sub updatefields { # rec
my $marcrec = shift || return;
my $template = shift;
my $do_rebuild_map = $template->{'rebuild_map'};
my $tag = $template->{'field'};
my $rafieldrefs = shift;
my @fieldrefs = @$rafieldrefs;
my $pos = 0;
( run in 0.225 second using v1.01-cache-2.11-cpan-95122f20152 )