line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::MARC::Count; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
107204
|
use strict; |
|
4
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
98
|
|
4
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
96
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
1688
|
use Class::Utils qw(set_params); |
|
4
|
|
|
|
|
108132
|
|
|
4
|
|
|
|
|
66
|
|
7
|
4
|
|
|
4
|
|
254
|
use English; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
23
|
|
8
|
4
|
|
|
4
|
|
8655
|
use Getopt::Std; |
|
4
|
|
|
|
|
212
|
|
|
4
|
|
|
|
|
225
|
|
9
|
4
|
|
|
4
|
|
1712
|
use MARC::File::XML (BinaryEncoding => 'utf8', RecordFormat => 'MARC21'); |
|
4
|
|
|
|
|
442882
|
|
|
4
|
|
|
|
|
36
|
|
10
|
4
|
|
|
4
|
|
1989
|
use Unicode::UTF8 qw(encode_utf8); |
|
4
|
|
|
|
|
1791
|
|
|
4
|
|
|
|
|
1431
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.02; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Constructor. |
15
|
|
|
|
|
|
|
sub new { |
16
|
6
|
|
|
6
|
1
|
7020
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create object. |
19
|
6
|
|
|
|
|
16
|
my $self = bless {}, $class; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Process parameters. |
22
|
6
|
|
|
|
|
28
|
set_params($self, @params); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Object. |
25
|
5
|
|
|
|
|
42
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Run. |
29
|
|
|
|
|
|
|
sub run { |
30
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Process arguments. |
33
|
4
|
|
|
|
|
16
|
$self->{'_opts'} = { |
34
|
|
|
|
|
|
|
'h' => 0, |
35
|
|
|
|
|
|
|
}; |
36
|
4
|
100
|
66
|
|
|
20
|
if (! getopts('h', $self->{'_opts'}) || @ARGV < 1 |
|
|
|
66
|
|
|
|
|
37
|
|
|
|
|
|
|
|| $self->{'_opts'}->{'h'}) { |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
146
|
print STDERR "Usage: $0 [-h] [--version] marc_xml_file\n"; |
40
|
2
|
|
|
|
|
23
|
print STDERR "\t-h\t\tPrint help.\n"; |
41
|
2
|
|
|
|
|
19
|
print STDERR "\t--version\tPrint version.\n"; |
42
|
2
|
|
|
|
|
17
|
print STDERR "\tmarc_xml_file\tMARC XML file.\n"; |
43
|
2
|
|
|
|
|
22
|
return 1; |
44
|
|
|
|
|
|
|
} |
45
|
2
|
|
|
|
|
63
|
$self->{'_marc_xml_file'} = shift @ARGV; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
24
|
my $marc_file = MARC::File::XML->in($self->{'_marc_xml_file'}); |
48
|
2
|
|
|
|
|
187
|
my $ret_hr = {}; |
49
|
2
|
|
|
|
|
4
|
my $num = 1; |
50
|
2
|
|
|
|
|
4
|
my $previous_record; |
51
|
2
|
|
|
|
|
3
|
while (1) { |
52
|
5
|
|
|
|
|
10
|
my $record = eval { |
53
|
5
|
|
|
|
|
20
|
$marc_file->next; |
54
|
|
|
|
|
|
|
}; |
55
|
5
|
100
|
|
|
|
8916
|
if ($EVAL_ERROR) { |
56
|
1
|
50
|
|
|
|
201
|
print STDERR "Cannot process '$num' record. ". |
57
|
|
|
|
|
|
|
( |
58
|
|
|
|
|
|
|
defined $previous_record |
59
|
|
|
|
|
|
|
? "Previous record is ".encode_utf8($previous_record->title)."\n" |
60
|
|
|
|
|
|
|
: '' |
61
|
|
|
|
|
|
|
); |
62
|
1
|
|
|
|
|
20
|
print STDERR "Error: $EVAL_ERROR\n"; |
63
|
1
|
|
|
|
|
5
|
next; |
64
|
|
|
|
|
|
|
} |
65
|
4
|
100
|
|
|
|
12
|
if (! defined $record) { |
66
|
2
|
|
|
|
|
5
|
last; |
67
|
|
|
|
|
|
|
} |
68
|
2
|
|
|
|
|
33
|
$previous_record = $record; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
4
|
$num++; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Print out. |
74
|
2
|
|
|
|
|
99
|
print $num."\n"; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
31
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |