#!/usr/bin/perl # fu-extract.pl - given a file of MARC records, extract records with a specific (FU) value in 952$o # Eric Lease Morgan # March 31, 2016 - first cut # require use MARC::Batch; use strict; # sanity check my $file = $ARGV[ 0 ]; if ( ! $file ) { print "Usage: $0 \n"; exit; } # initialize my $batch = MARC::Batch->new( 'USMARC', $file ); my $index = 0; binmode STDOUT, ':utf8'; # process each record while ( my $record = $batch->next ) { # initialize my $id = $record->field( '001')->as_string; # debug; monitor $index++; print STDERR "$index $id\t\r"; # look for a holding field if ( $record->field( '952' ) ) { # check for subfield o if ( $record->field( '952' )->subfield( 'o' ) ) { # extract the value my $callNumber = $record->field( '952' )->subfield( 'o' ); # check to see if it is something we want if ( $callNumber =~ /^FU/ ) { # print the record to STDOUT print $record->as_usmarc; } } } } # done exit;