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 );
32 # FIXME - Fix the POD to conform to Perl style. In particular,
33 # functions get an =item, not a =head2.
43 our $VERSION = '0.93';
47 use MARC::File::USMARC;
49 my $file = MARC::File::USMARC->in( $filename );
51 while ( my $marc = $file->next() ) {
65 Opens a file for input.
74 filename => $filename,
79 if ( !open( $self->{fh}, "<", $filename ) ) {
81 $MARC::File::ERROR = "Couldn't open $filename: $!";
99 # if ( !open( $self->{fh}, "<", $filename ) ) {
101 # $MARC::File::ERROR = "Couldn't open $filename: $!";
108 die "Not yet written";
113 Reads the next record from the file handle passed in.
120 my $rec = $self->_next();
122 return $rec ? $self->decode($rec) : undef;
127 Skips over the next record in the file. Same as C<next()>,
128 without the overhead of parsing a record you're going to throw away
138 my $rec = $self->_next();
140 return $rec ? 1 : undef;
146 close( $self->{fh} );
152 sub _unimplemented() {
156 warn "Method $method must be overridden";
159 sub write { $_[0]->_unimplemented("write"); }
160 sub decode { $_[0]->_unimplemented("decode"); }
162 # NOTE: _gripe can be called as an object method, or not. Your choice.
165 shift if ref($_[0]) =~ /^MARC::File/; # Skip first parm if it's a $self
166 $ERROR = join( "", @_ );
176 =head1 RELATED MODULES
184 =item * C<out()> method
186 We only handle files for input right now.
194 This code may be distributed under the same terms as Perl itself.
196 Please note that these modules are not products of or supported by the
197 employers of the various contributors to the code.
201 Andy Lester, E<lt>marc@petdance.comE<gt> or E<lt>alester@flr.follett.comE<gt>