install-osrf.sh: set ejabberd host correctly during registration on prod
[sitka/sitka-tools.git] / marc_export_custom / print901c.pl
CommitLineData
5cef4c16
RJ
1#!/usr/bin/perl
2use MARC::Batch;
3use strict;
4use warnings;
d37cd923 5use Encode qw(:fallback_all);
5cef4c16
RJ
6
7my $batch = MARC::Batch->new( 'USMARC', @ARGV );
d37cd923 8my $oldencoding = $PerlIO::encoding::fallback;
5cef4c16
RJ
9$batch->strict_off();
10$batch->warnings_off();
11
d37cd923
RJ
12my ($count_raw, $count_attempted, $count_901c) = (0, 0, 0);
13eval {
14 while ( my $marc = $batch->next ) {
15 $PerlIO::encoding::fallback = Encode::WARN_ON_ERR | Encode::PERLQQ;
16 $count_attempted++;
17 eval {
18 my $field_901c = $marc->subfield(901,"c");
19 if(defined $field_901c) {
20 chomp $field_901c;
21 $count_901c++ if ($field_901c =~ /^.+$/);
22 printf "%s\n",$field_901c;
23 }
24 $count_raw++;
25 };
26 warn "Inner: $@" if $@;
27 }
28};
29warn "Outer: $@" if $@;
30
31$PerlIO::encoding::fallback = $oldencoding;
32printf STDERR "Count (attempted): %d\n",$count_attempted;
33printf STDERR "Count (raw): %d\n",$count_raw;
34printf STDERR "Count (901c): %d\n",$count_901c;