On Thursday, November 6, 2003, at 01:14 PM, Leif Andersson wrote:

With the same BAD record we try $subfield = eval { $record->field($tag)->subfield($sub) }
This is the only case where we have to put the code in eval.
Should MARC:: take care of the eval for us? I am beginning to think so.

No, it can't. Just add your own error checking, something like this for example:


   my $field = $record->field($tag) || die "No tag '$tag' in record";
   $subfield = $field->subfield($sub);

MARC::Record::field has no way of knowing that your code will invoke the method 'subfield' on the value it returns. You could also do it like this if you want to keep things concise:

$subfield = ($record->field($tag) || die "No tag '$tag' in record")->subfield($sub);

But that's getting a wee bit obfuscated.

Paul.

--
Paul Hoffman :: Taubman Medical Library :: Univ. of Michigan
[EMAIL PROTECTED] :: [EMAIL PROTECTED] :: http://www.nkuitse.com/



Reply via email to