1MARC::Batch(3)        User Contributed Perl Documentation       MARC::Batch(3)
2
3
4

NAME

6       MARC::Batch - Perl module for handling files of MARC::Record objects
7

SYNOPSIS

9       MARC::Batch hides all the file handling of files of "MARC::Record"s.
10       "MARC::Record" still does the file I/O, but "MARC::Batch" handles the
11       multiple-file aspects.
12
13           use MARC::Batch;
14
15           my $batch = MARC::Batch->new( 'USMARC', @files );
16           while ( my $marc = $batch->next ) {
17               print $marc->subfield(245,"a"), "\n";
18           }
19

EXPORT

21       None.  Everything is a class method.
22

METHODS

24       new( $type, @files )
25
26       Create a "MARC::Batch" object that will process @files.
27
28       $type must be either "USMARC" or "MicroLIF".  If you want to specify
29       "MARC::File::USMARC" or "MARC::File::MicroLIF", that's OK, too. "new()"
30       returns a new MARC::Batch object.
31
32       @files can be a list of filenames:
33
34           my $batch = MARC::Batch->new( 'USMARC', 'file1.marc', 'file2.marc' );
35
36       Your @files may also contain filehandles. So if you've got a large file
37       that's gzipped you can open a pipe to gzip and pass it in:
38
39           my $fh = IO::File->new( 'gunzip -c marc.dat.gz ⎪' );
40           my $batch = MARC::Batch->new( 'USMARC', $fh );
41
42       And you can mix and match if you really want to:
43
44           my $batch = MARC::Batch->new( 'USMARC', $fh, 'file1.marc' );
45
46       next()
47
48       Read the next record from that batch, and return it as a MARC::Record
49       object.  If the current file is at EOF, close it and open the next one.
50       "next()" will return "undef" when there is no more data to be read from
51       any batch files.
52
53       By default, "next()" also will return "undef" if an error is encoun‐
54       tered while reading from the batch. If not checked for this can cause
55       your iteration to terminate prematurely. To alter this behavior, see
56       "strict_off()". You can retrieve warning messages using the "warn‐
57       ings()" method.
58
59       Optionally you can pass in a filter function as a subroutine reference
60       if you are only interested in particular fields from the record. This
61       can boost performance.
62
63       strict_off()
64
65       If you would like "MARC::Batch" to continue after it has encountered
66       what it believes to be bad MARC data then use this method to turn
67       strict OFF.  A call to "strict_off()" always returns true (1).
68
69       "strict_off()" can be handy when you don't care about the quality of
70       your MARC data, and just want to plow through it. For safety,
71       "MARC::Batch" strict is ON by default.
72
73       strict_on()
74
75       The opposite of "strict_off()", and the default state. You shouldn't
76       have to use this method unless you've previously used "strict_off()",
77       and want it back on again.  When strict is ON calls to next() will
78       return undef when an error is encountered while reading MARC data.
79       strict_on() always returns true (1).
80
81       warnings()
82
83       Returns a list of warnings that have accumulated while processing a
84       particular batch file. As a side effect the warning buffer will be
85       cleared.
86
87           my @warnings = $batch->warnings();
88
89       This method is also used internally to set warnings, so you probably
90       don't want to be passing in anything as this will set warnings on your
91       batch object.
92
93       "warnings()" will return the empty list when there are no warnings.
94
95       warnings_off()
96
97       Turns off the default behavior of printing warnings to STDERR. However,
98       even with warnings off the messages can still be retrieved using the
99       warnings() method if you wish to check for them.
100
101       "warnings_off()" always returns true (1).
102
103       warnings_on()
104
105       Turns on warnings so that diagnostic information is printed to STDERR.
106       This is on by default so you shouldn't have to use it unless you've
107       previously turned off warnings using warnings_off().
108
109       warnings_on() always returns true (1).
110
111       filename()
112
113       Returns the currently open filename or "undef" if there is not cur‐
114       rently a file open on this batch object.
115
117       MARC::Record, MARC::Lint
118

TODO

120       None yet.  Send me your ideas and needs.
121

LICENSE

123       This code may be distributed under the same terms as Perl itself.
124
125       Please note that these modules are not products of or supported by the
126       employers of the various contributors to the code.
127

AUTHOR

129       Andy Lester, "<andy@petdance.com>"
130
131
132
133perl v5.8.8                       2005-04-27                    MARC::Batch(3)
Impressum