5 MARC::File - Base class for files of MARC records
12 use vars qw( $VERSION $ERROR );
22 our $VERSION = '0.93';
26 use MARC::File::USMARC;
28 my $file = MARC::File::USMARC->in( $filename );
30 while ( my $marc = $file->next() ) {
44 Opens a file for input.
53 filename => $filename,
58 if ( !open( $self->{fh}, "<", $filename ) ) {
60 $MARC::File::ERROR = "Couldn't open $filename: $!";
78 # if ( !open( $self->{fh}, "<", $filename ) ) {
80 # $MARC::File::ERROR = "Couldn't open $filename: $!";
87 die "Not yet written";
92 Reads the next record from the file handle passed in.
99 my $rec = $self->_next();
101 return $rec ? $self->decode($rec) : undef;
106 Skips over the next record in the file. Same as C<next()>,
107 without the overhead of parsing a record you're going to throw away
117 my $rec = $self->_next();
119 return $rec ? 1 : undef;
125 close( $self->{fh} );
131 sub _unimplemented() {
135 warn "Method $method must be overridden";
138 sub write { $_[0]->_unimplemented("write"); }
139 sub decode { $_[0]->_unimplemented("decode"); }
141 # NOTE: _gripe can be called as an object method, or not. Your choice.
144 shift if ref($_[0]) =~ /^MARC::File/; # Skip first parm if it's a $self
145 $ERROR = join( "", @_ );
155 =head1 RELATED MODULES
163 =item * C<out()> method
165 We only handle files for input right now.
173 This code may be distributed under the same terms as Perl itself.
175 Please note that these modules are not products of or supported by the
176 employers of the various contributors to the code.
180 Andy Lester, E<lt>marc@petdance.comE<gt> or E<lt>alester@flr.follett.comE<gt>