18 |
|
|
19 |
=head1 VERSION |
=head1 VERSION |
20 |
|
|
21 |
Version 0.03 |
Version 0.04 |
22 |
|
|
23 |
=cut |
=cut |
24 |
|
|
25 |
our $VERSION = '0.03'; |
our $VERSION = '0.04'; |
26 |
|
|
27 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
28 |
|
|
91 |
$log->logdie("need field name in line $curr_line: $l") unless (defined($fld)); |
$log->logdie("need field name in line $curr_line: $l") unless (defined($fld)); |
92 |
|
|
93 |
if (@d) { |
if (@d) { |
94 |
$v->{$fld} = \@d; |
$v->{$fld} = [ map { |
95 |
|
my $sf = $_; |
96 |
|
if ( $sf =~ s/!(\*)?$/$1/ ) { |
97 |
|
$self->{must_exist_sf}->{ $fld }->{ $sf }++; |
98 |
|
}; |
99 |
|
$sf; |
100 |
|
} @d ]; |
101 |
} else { |
} else { |
102 |
$v->{$fld} = 1; |
$v->{$fld} = 1; |
103 |
} |
} |
169 |
|
|
170 |
delete($v->{subfields}) if (defined($v->{subfields})); |
delete($v->{subfields}) if (defined($v->{subfields})); |
171 |
|
|
172 |
|
my $subfields; |
173 |
|
|
174 |
foreach my $sf (keys %{ $v }) { |
foreach my $sf (keys %{ $v }) { |
175 |
|
|
176 |
|
$subfields->{ $sf }++; |
177 |
|
|
178 |
# is non-repeatable but with multiple values? |
# is non-repeatable but with multiple values? |
179 |
if ( ! first { $_ eq $sf.'*' } @{$r->{$f}} ) { |
if ( ! first { $_ eq $sf.'*' } @{$r->{$f}} ) { |
180 |
if ( ref($v->{$sf}) eq 'ARRAY' ) { |
if ( ref($v->{$sf}) eq 'ARRAY' ) { |
196 |
'repeatable in: ' . |
'repeatable in: ' . |
197 |
join('', _pack_subfields_hash( $h, 1) ); |
join('', _pack_subfields_hash( $h, 1) ); |
198 |
} |
} |
199 |
|
|
200 |
|
if ( defined( $self->{must_exist_sf}->{$f} ) ) { |
201 |
|
foreach my $sf (sort keys %{ $self->{must_exist_sf}->{$f} }) { |
202 |
|
warn "====> $f $sf must exist\n"; |
203 |
|
push @errors, "$f missing required subfield $sf" |
204 |
|
unless ( |
205 |
|
defined( $subfields->{$f} ) && |
206 |
|
defined( $subfields->{$f}->{$sf} ) |
207 |
|
) |
208 |
|
} |
209 |
|
} |
210 |
|
|
211 |
} |
} |
212 |
} elsif (ref($v) eq 'HASH') { |
} elsif (ref($v) eq 'HASH') { |
213 |
push @errors, "$f has subfields which is not valid"; |
push @errors, "$f has subfields which is not valid"; |