+ support splitting of config yml to multiple files
+ add set and get to create in-memory lookup
+ support marc_remove('*')
++ fix-length fields (<100) support [2.29]
- load_ds/save_ds should use on-disk hash to preserve inodes
- leader(position,...), indicator(field,nr) nr=1|2 for MARC input
-- fix-length fields (<100) support
- validate should ignore modify_file
- add option to specify output marc path in config.yml
- add dBase input format
tag search display
marc marc_indicators marc_repeatable_subfield
- marc_compose marc_leader
+ marc_compose marc_leader marc_fixed
marc_duplicate marc_remove marc_count
marc_original_order
=head1 VERSION
-Version 0.27
+Version 0.28
=cut
-our $VERSION = '0.27';
+our $VERSION = '0.28';
=head1 SYNOPSIS
}
}
+=head2 marc_fixed
+
+Create control/indentifier fields with values in fixed positions
+
+ marc_fixed('008', 00, '070402');
+ marc_fixed('008', 39, '|');
+
+Positions not specified will be filled with spaces (C<0x20>).
+
+There will be no effort to extend last specified value to full length of
+field in standard.
+
+=cut
+
+sub marc_fixed {
+ my ($f, $pos, $val) = @_;
+ die "need marc(field, position, value)" unless defined($f) && defined($pos);
+
+ my $update = 0;
+
+ map {
+ if ($_->[0] eq $f) {
+ my $old = $_->[1];
+ if (length($old) < $pos) {
+ $_->[1] .= ' ' x ( $pos - length($old) ) . $val;
+ warn "## marc_fixed($f,$pos,'$val') append '$old' -> '$_->[1]'\n";
+ } else {
+ $_->[1] = substr($old, 0, $pos) . $val . substr($old, $pos + length($val));
+ warn "## marc_fixed($f,$pos,'$val') update '$old' -> '$_->[1]'\n";
+ }
+ $update++;
+ }
+ } @{ $marc_record->[ $marc_record_offset ] };
+
+ if (! $update) {
+ my $v = ' ' x $pos . $val;
+ push @{ $marc_record->[ $marc_record_offset ] }, [ $f, $v ];
+ warn "## marc_fixed($f,$pos,'val') created '$v'\n";
+ }
+}
+
=head2 marc
Save value for MARC field
use strict;
-use Test::More tests => 332;
+use Test::More tests => 335;
use Test::Exception;
use Cwd qw/abs_path/;
use blib;
'^aa1^bb1^aa2^bb2^cc1^cc2',
'_pack_subfields_hash( $h, 1 )'
);
+
+ _clean_ds();
+ test_s(qq{
+ marc_fixed('008', 0, 'abcdef');
+ marc_fixed('000', 5, '5');
+ marc_fixed('000', 10, 'A');
+ marc_fixed('000', 0, '0');
+ });
+ ok( my $m = WebPAC::Normalize::_get_marc_fields(), '_get_marc_fields');
+ diag dump( $m );
+ is_deeply( WebPAC::Normalize::_get_marc_fields(),
+ [
+ ["008", "abcdef"],
+ # 0....5....10
+ ["000", "0 5 A"]
+ ]
+ );
}