Hey Andy, That does sound like an annoying problem. Someone else might have a better answer, but I think I have a clever solution...
Instead of using MARC::File::XML directly, you can use MARC::Batch instead: my $batch = MARC::Batch->new( 'XML', $filename ); According to the MARC::Batch documentation, you can actually use a file handle instead of a file name: http://search.cpan.org/~gmcharlt/MARC-Record-2.0.7/lib/MARC/Batch.pm#new(_$type,_@files_) . You should be able to create an "in-memory" file handle that points to your scalar variable holding your XML. Like so: open(my $fh, "<", \$variable); You should be able to pass in the $fh to MARC::Batch like this: my $batch = MARC::Batch->new( 'XML', $fh ); Now I haven't tried this... but in theory it should work. On Thu, Apr 19, 2018 at 10:25 AM, Andy Kohler <akohler...@gmail.com> wrote: > Hi - > > I'm pulling records from the WorldCat Search API in MARCXML, and need to > convert them to binary MARC for further evaluation, which I'll do via > MARC::Record. > > Problem: Converting from MARCXML via MARC::File::XML seems to require > reading the records from a file. I've already got the XML stored in a > variable, retrieved via LWP::Simple->get(). > > Do I have to write the XML to a file, then read it in again to convert > it? Or am I just missing something obvious? > > I've tried things like: > $xml = get($api_call); # also verified that $xml now contains MARCXML for > 1 or more records > my $batch = MARC::File::XML->in($xml); > while (my $record = $batch->next()) { > print $record; > } > but I get the error: Can't call method "next" on an undefined value > > Thanks --Andy > >