X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=marc_sf.pm;h=0cae11307cef126d4e111442eeddbbf646bbe80b;hb=6209bea7c9ed99dacfbf229e709d1da3a26f6457;hp=728759eb6f3c81d9dbdab7eb7d8bbe15d38393a9;hpb=4009de50fd607079a0bf898472d82d6df32a0f7b;p=webpac diff --git a/marc_sf.pm b/marc_sf.pm index 728759e..0cae113 100644 --- a/marc_sf.pm +++ b/marc_sf.pm @@ -1,18 +1,20 @@ # -# get_sf($marc,'field'[,'subfield']) +# marc_sf($marc,'field'[,'subfield']) # -# e.g. get_sf($row,'700','a') +# e.g. marc_sf($row,'700','a') # -sub get_sf { - my $marc = shift @_; - my $f = shift @_; +sub marc_sf { + my $marc = shift @_ || die "marc_sf: needs record"; + my $f = shift @_ || die "marc_sf: needs field name"; my $s = shift @_; my $i = shift @_ || 0; - my $out; + my $rec = $main::cache->{marc_record} || die '$cache->{marc_record} is undefined!'; - return $marc->getfirstvalue({record=>$marc->marc_count(),field=>$f,subfield=>$s,delimiter=>" "}); + my @out = $marc->getvalue({record=>$rec,field=>$f,subfield=>$s}); + + return $out[$i] if (@out && $out[$i]); } 1;