Hi,
In Perl, to catch errors, you can use eval.

Ex.
eval { die "my error" };
warn "an error was occured : $@" if $@;
( http://perldoc.perl.org/functions/eval.html )

Others modules exist like Try::Tiny (
http://search.cpan.org/~doy/Try-Tiny-0.11/lib/Try/Tiny.pm ) which simulate a
use as in many langages.

Good luck ;)

Jonathan

2011/10/14 Zhang, Bin <bzh...@csus.edu>

> Hi,
>
> I have to admit my Perl skill is very limited, so this may be a dumb
> question, but I can't seem to find answer.   When I use MARC::Batch to read
> records from our catalog (III) export file, I can't seem to find a way to
> skip an error record.   When I ran the following against an III export MARC
> file, it stopped at a record with error.
>
> utf8 "\xBC" does not map to Unicode at /usr/lib/perl/5.10/Encode.pm line
> 174.
>
> Ideally I would like to be able to log the error and move to the next
> record.
>
> Any help you can offer is greatly appreciated!
>
>
> --script--
> my $batch = MARC::Batch->new('USMARC', '../full_export.out');
> $batch->strict_off();
> $batch->warnings_off();
>
> my $linter = MARC::Lint->new();
> my $counter = 0;
>
> while(my $record = $batch->next() ) {
>    $counter++;
>    if($counter != 22507) {
>        $linter->check_record($record);
>        my @warnings = $linter->warnings();
>        if(@warnings) {
>            print "RECORD $counter\n";
>            print join("\n", @warnings), "\n";
>        }
>    }
> }
>
>
> ---
> Bin Zhang
> Digital Information Services Librarian
> Library 3501D
> Library Systems & IT Services, University Library
> California State University, Sacramento
> 2000 State University Drive East, Sacramento, CA 95819-6039
> (916) 278-5664 (O); (916) 278-3891 (F)
> bzhang AT csus DOT edu
>
>

Reply via email to