X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=marc_sf.pm;h=0cae11307cef126d4e111442eeddbbf646bbe80b;hb=a4ef37c32a0961f92d3da96ec772d007fbdb95a3;hp=7e2c6719b80facf0f3d4f2725ca0f44e70779585;hpb=7073f1c1ca5d3c3ccc47e6a2551411113cb9724f;p=webpac diff --git a/marc_sf.pm b/marc_sf.pm index 7e2c671..0cae113 100644 --- a/marc_sf.pm +++ b/marc_sf.pm @@ -4,13 +4,16 @@ # e.g. marc_sf($row,'700','a') # sub marc_sf { - my $marc = shift @_; - my $f = shift @_; + 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 = $marc->getvalue({record=>$marc->marc_count(),field=>$f,subfield=>$s,delimiter=>" "}); + my $rec = $main::cache->{marc_record} || die '$cache->{marc_record} is undefined!'; + + my @out = $marc->getvalue({record=>$rec,field=>$f,subfield=>$s}); + return $out[$i] if (@out && $out[$i]); }