> From: Bryan Baldus [mailto:[EMAIL PROTECTED]
> Sent: 18 August, 2004 09:24
> Subject: Warnings during decode() of raw MARC
>
> I'm probably missing something obvious, but I have been
> unsuccessful in trying to capture the warnings reported by
> MARC::Record that are set by MARC::File::USMARC->decode(). Is
> there a simple way to store the warnings reported during the
> decode() process (using a MARC::Record or MARC::Batch object)?
>
How about this technique:
#!perl
package main;
sub out {
print STDERR "ERR: Error 1\n";
print STDERR "ERR: Error 2\n";
print STDERR "ERR: Error 3\n";
return;
}
sub main {
my @errs = ();
open SAVERR, ">&STDERR";
open STDERR, ">errors.txt";
open GETERR, "<errors.txt";
main::out;
while (<GETERR>) {
push(@errs,$_);
}
close(GETERR);
open STDERR, ">&SAVERR";
print STDOUT scalar(@errs),"\n";
return 0;
}
exit main::main;