develooper Front page | perl.perl4lib | Postings from July 2008

Requesting help with simple MARC::File::XML program

From:
Anne L. Highsmith
Date:
July 20, 2008 20:20
Subject:
Requesting help with simple MARC::File::XML program
I have a file of usmarc records which I want to read into a program and print to a file as MARC xml. Here's my program so far:

#########################################################
#!/usr/local/bin/perl
use strict;
use warnings;
use MARC::Record;
use MARC::Batch;
use MARC::File::XML;

my $infile = 'updated_dissertation_records';
my $file = MARC::File::XML->out('updated_dissertation_records.xml', 'UTF-8' );

my $batch = MARC::Batch->new( 'USMARC', $infile);
for (my $i = 0; $i < 3; $i++) {
        my $record = $batch->next();
        $file->write($record);
}
#########################################################

First question -- I can't get past the my $file = MARC::File::XML->out('updated_dissertation_records.xml', 'UTF-8' );
statement.  When I run the program, that line gets the error:
usage $fh->binmode([LAYER]) at /usr/local/perl/5.8/lib/site_perl/5.8.7/MARC/File/XML.pm line 195

Two -- does the "$file->write()" statement expect a MARC::Record object, an XML stream, or a marc record string? I've assumed a MARC::Record object. If it expects an XML stream, what is the best method for what I'm trying to do to get my marc record into an appropriate XML stream?




Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About