4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
23 MARC::File - Base class for files of MARC records
30 use vars qw( $VERSION $ERROR );
40 our $VERSION = '0.93';
44 use MARC::File::USMARC;
46 my $file = MARC::File::USMARC->in( $filename );
48 while ( my $marc = $file->next() ) {
62 Opens a file for input.
71 filename => $filename,
76 if ( !open( $self->{fh}, "<", $filename ) ) {
78 $MARC::File::ERROR = "Couldn't open $filename: $!";
96 # if ( !open( $self->{fh}, "<", $filename ) ) {
98 # $MARC::File::ERROR = "Couldn't open $filename: $!";
105 die "Not yet written";
110 Reads the next record from the file handle passed in.
117 my $rec = $self->_next();
119 return $rec ? $self->decode($rec) : undef;
124 Skips over the next record in the file. Same as C<next()>,
125 without the overhead of parsing a record you're going to throw away
135 my $rec = $self->_next();
137 return $rec ? 1 : undef;
143 close( $self->{fh} );
149 sub _unimplemented() {
153 warn "Method $method must be overridden";
156 sub write { $_[0]->_unimplemented("write"); }
157 sub decode { $_[0]->_unimplemented("decode"); }
159 # NOTE: _gripe can be called as an object method, or not. Your choice.
162 shift if ref($_[0]) =~ /^MARC::File/; # Skip first parm if it's a $self
163 $ERROR = join( "", @_ );
173 =head1 RELATED MODULES
181 =item * C<out()> method
183 We only handle files for input right now.
191 This code may be distributed under the same terms as Perl itself.
193 Please note that these modules are not products of or supported by the
194 employers of the various contributors to the code.
198 Andy Lester, E<lt>marc@petdance.comE<gt> or E<lt>alester@flr.follett.comE<gt>