#!/usr/bin/perl -w

#use utf8;
#use Time::localtime;
use MARC::Field;
use MARC::File::USMARC;
#use MARC::Charset;
use Getopt::Std;
$| = 1;

%options=();
getopts("p:",\%options);
$pos = $options{p};
if (!$pos || $pos =~ m/[\D]+/) {
    print "Usage: viewmarc.pl -pPOSITION MARC_FILE\n";
    exit 1;
}
($pos) || ($pos = 1);
my $p = 1;
foreach my $file (@ARGV) {
    my $marcfile = MARC::File::USMARC->in( "$file" );

    while ($p < $pos) {
        $marcfile->skip();
        $p++;
    }
    my $record = $marcfile->next();
    print $record->as_formatted, "\n";
    last;

    $marcfile->close();
}

exit 0;
