[libcatmandu-marc-perl] 192/208: Adding the rename of MARC fields to the tutorial
Jonas Smedegaard
dr at jones.dk
Sat Oct 28 03:42:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag upstream/1.19
in repository libcatmandu-marc-perl.
commit 3f98196dc9a313d666ece508d52bccaca6bb12b6
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date: Thu Jul 20 11:34:32 2017 +0200
Adding the rename of MARC fields to the tutorial
---
lib/Catmandu/MARC/Tutorial.pod | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/lib/Catmandu/MARC/Tutorial.pod b/lib/Catmandu/MARC/Tutorial.pod
index febddf6..8e8ffdc 100644
--- a/lib/Catmandu/MARC/Tutorial.pod
+++ b/lib/Catmandu/MARC/Tutorial.pod
@@ -232,6 +232,35 @@ output
$ catmandu -D convert MARC to Null --fix myfix.fix < data.mrc
+=head2 Rename MARC subfields
+
+In the example below we rename each $1 subfield in the MARC record to $0 using
+the L<Catmandu::Fix::marc_cut>, L<Catmandu::Fix::marc_paste> and L<Catmandu::Fix::rename>
+fixes:
+
+ # For each marc field...
+ do marc_each()
+ # Cut the field into tmp..
+ marc_cut(***,tmp)
+
+ # Rename every 1 subfield to 0
+ rename(tmp.*.subfields.*,1,0)
+
+ # And paste it back
+ marc_paste(tmp)
+ end
+
+Put this Fix script in a file C<myfix.fix> and execute the Catmandu command:
+
+ $ catmandu convert MARC to MARC --fix myfix.fix < data.mrc > output.mrc
+
+The C<marc_each> bind will loop over all the MARC fields. With C<marc_cut> we
+store any field (C<***> matches every field) into a C<tmp> field. The C<marc_cut>
+creates an array structure in C<tmp> which is easy to process using the Fix
+language. Using the C<rename> function we search for all the subfields, and replace
+the field matching the regular expression C<1> with C<0>. At the end, we paste
+back the C<tmp> field into the record.
+
=head1 WRITING
=head2 Convert a MARC record into a MARC record (do nothing)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git
More information about the Pkg-perl-cvs-commits
mailing list