.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "MARC::MIR::Tutorial 3pm"
.TH MARC::MIR::Tutorial 3pm "2023-02-09" "perl v5.36.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
MARC::MIR::Tutorial \- Tutorial for MARC::MIR DSL
.SS "the \s-1DSL\s0"
.IX Subsection "the DSL"
to make things more readable and less error prone, we also add a \s-1DSL.\s0 Every keywords of this \s-1DSL\s0 works the same way. \s-1FIXME :\s0 explain.
.PP
also, iso2709_records_of is an helper that stream the records of an \s-1ISO2709\s0 formatted file.
.SS "some examples"
.IX Subsection "some examples"
the perfect boilerplate
.PP
.Vb 4
\&    use autodie;
\&    use Modern::Perl;
\&    use Perlude;
\&    use MARC::MIR;
.Ve
.PP
print all the ids of the records (assuming the id is in 001, the common case)
.PP
.Vb 1
\&    now    { say record_id from_iso2709 } iso2709_records_of "biblio.marc";
.Ve
.PP
or
.PP
.Vb 1
\&    marawk { say $ID } "biblio.marc";
.Ve
.PP
remove every 9.. fields
.PP
.Vb 5
\&    now {
\&        $_ = from_iso2709;
\&        with_fields { @$_ = grep { (tag) !~ /^9/ } @$_ };
\&        print to_iso2709;
\&    } iso2709_records_of "biblio.marc";
.Ve
.PP
every 856$q must be jpeg
.PP
.Vb 9
\&    now {
\&        $_ = from_iso2709;
\&        map_fields {
\&            tag eq \*(Aq856\*(Aq and map_subfields {
\&                (tag) eq \*(Aqz\*(Aq and with_value { $_ = \*(Aqjpeg\*(Aq }
\&            }
\&        }
\&        with_fields { @$_ = grep_fields { (tag) !~ /^9/ } @$_ };
\&    } iso2709_records_of "biblio.marc";
.Ve
.PP
or
.PP
.Vb 1
\&    marawk { map_values { $_ = \*(Aqjpeg\*(Aq } [qw< 856 z >] } "biblio.marc"
.Ve
.PP
collect every 856$z by id
.PP
.Vb 3
\&    use Modern::Perl;
\&    use YAML;
\&    use MARC::MIR;
\&
\&    my %seen;
\&    marawk {
\&        map_values { push @{ $seen{$ID} }, $_ } [qw< 856 z >]
\&    } "data/*.RAW";
\&    say YAML::Dump \e%seen;
.Ve
.SS "marawk"
.IX Subsection "marawk"
# \s-1TODO:\s0