'b', rec('200','e'),
'c', rec('200','f'),
# FIXME append to last subfield
-# '+', prefix('. ', rec('200','c') ),
+ '+', prefix('. ', rec('200','c') ),
);
)
);
-_debug(2);
+#_debug(2);
marc_indicators('700', 1, ' ');
)
);
-_debug(0);
+#_debug(0);
if ( rec('710','f') ) {
=head1 VERSION
-Version 0.14
+Version 0.15
=cut
-our $VERSION = '0.14';
+our $VERSION = '0.15';
=head1 SYNOPSIS
'c', rec('200','c')
);
+If you specify C<+> for subfield, value will be appended
+to previous defined subfield.
+
=cut
sub marc_compose {
next unless (defined($v) && $v !~ /^\s*$/);
from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding);
- push @$m, ( $sf, $v );
warn "## ++ marc_compose($f,$sf,$v) ", dump( $m ),$/ if ($debug > 1);
+ if ($sf ne '+') {
+ push @$m, ( $sf, $v );
+ } else {
+ $m->[ $#$m ] .= $v;
+ }
}
warn "## marc_compose current marc = ", dump( $m ),$/ if ($debug > 1);
use strict;
-use Test::More tests => 147;
+use Test::More tests => 150;
use Test::Exception;
use Cwd qw/abs_path/;
use blib;
],
);
+ test_rec_rules(
+ 'marc_compose with + subfields',
+ { '200' => [{ a => 'foo ; bar', b => 42, c => 'baz' }] },
+ qq{
+ marc_compose('900',
+ 'a', rec(200,'a'),
+ '+', prefix(" * ", rec(200,'c')),
+ 'b', rec(200,'b'),
+ '+', prefix(" : ", rec(200,'c')),
+ );
+ },
+ [
+ [ '900', ' ', ' ', 'a', 'foo ; bar * baz', 'b', '42 : baz' ]
+ ],
+ );
+
#
# test rules
#