1MARC::File(3) User Contributed Perl Documentation MARC::File(3)
2
3
4
6 MARC::File - Base class for files of MARC records
7
9 use MARC::File::USMARC;
10
11 # If you have weird control fields...
12 use MARC::Field;
13 MARC::Field->allow_controlfield_tags('FMT', 'LDX');
14
15 my $file = MARC::File::USMARC->in( $filename );
16
17 while ( my $marc = $file->next() ) {
18 # Do something
19 }
20 $file->close();
21 undef $file;
22
24 None.
25
27 in()
28 Opens a file for import. Ordinarily you will use "MARC::File::USMARC"
29 or "MARC::File::MicroLIF" to do this.
30
31 my $file = MARC::File::USMARC->in( 'file.marc' );
32
33 Returns a "MARC::File" object, or "undef" on failure. If you
34 encountered an error the error message will be stored in
35 $MARC::File::ERROR.
36
37 Optionally you can also pass in a filehandle, and "MARC::File". will
38 "do the right thing".
39
40 my $handle = IO::File->new( 'gunzip -c file.marc.gz |' );
41 my $file = MARC::File::USMARC->in( $handle );
42
43 next( [\&filter_func] )
44 Reads the next record from the file handle passed in.
45
46 The $filter_func is a reference to a filtering function. Currently,
47 only USMARC records support this. See MARC::File::USMARC's "decode()"
48 function for details.
49
50 Returns a MARC::Record reference, or "undef" on error.
51
52 skip()
53 Skips over the next record in the file. Same as "next()", without the
54 overhead of parsing a record you're going to throw away anyway.
55
56 Returns 1 or undef.
57
58 warnings()
59 Simlilar to the methods in MARC::Record and MARC::Batch, "warnings()"
60 will return any warnings that have accumulated while processing this
61 file; and as a side-effect will clear the warnings buffer.
62
63 close()
64 Closes the file, both from the object's point of view, and the actual
65 file.
66
67 write()
68 Writes a record to the output file. This method must be overridden in
69 your subclass.
70
71 decode()
72 Decodes a record into a USMARC format. This method must be overridden
73 in your subclass.
74
76 MARC::Record
77
79 • "out()" method
80
81 We only handle files for input right now.
82
84 This code may be distributed under the same terms as Perl itself.
85
86 Please note that these modules are not products of or supported by the
87 employers of the various contributors to the code.
88
90 Andy Lester, "<andy@petdance.com>"
91
92
93
94perl v5.36.0 2022-07-22 MARC::File(3)