Anybody know what this USMARC.pm error is?

[email protected] (Mike Barrett) Sat, 21 May 2011 16:10:49 -0500
Newsgroups perl.perl4lib
Message-ID <[email protected]>
When I run the code below, it works fine for a couple thousand MARC records,
then starts this:
str outside of string at C:/Perl64/lib/bytes_heavy.pl line 11.
 of uninitialized value in integer eq (==) at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 175.
 of uninitialized value $tagdata in substr at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 178.
str outside of string at C:/Perl64/lib/bytes_heavy.pl line 11.
 of uninitialized value in integer eq (==) at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 175.
 of uninitialized value $tagdata in substr at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 178.
str outside of string at C:/Perl64/lib/bytes_heavy.pl line 11.
 of uninitialized value in integer eq (==) at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 175.
 of uninitialized value $tagdata in substr at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 178.
 of uninitialized value $tagdata in split at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 195.
 of uninitialized value $indicators in concatenation (.) or string at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 200.
str outside of string at C:/Perl64/lib/bytes_heavy.pl line 11.
 of uninitialized value in integer eq (==) at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 175.
 of uninitialized value $tagdata in substr at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 178.
 of uninitialized value $tagdata in split at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 195.
 of uninitialized value $indicators in concatenation (.) or string at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 200.

It does that a few dozen times, then finally dies with:
str outside of string at C:/Perl64/lib/bytes_heavy.pl line 11.
 of uninitialized value in integer eq (==) at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 175.
 of uninitialized value $tagdata in substr at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 178.
 of uninitialized value $tagdata in split at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 195.
 of uninitialized value $indicators in concatenation (.) or string at
C:/Perl64/site/lib/MARC/File/USMARC.pm line 200.
't call method "as_string" on an undefined value at getsomefields.pl line
25.

Code is attached.
(NOTE:  When I ran this, my @tags was written so that "24." was the first
$tag, so it pulled 001, but then choked on the 245.)

Here's the record it appears to have choked on while pulling the 245:
00791nam a2200229 a
450000100070000000500170000700800410002400700140006501100150007903500200009403500140011404000130012804900090014109000090015009900180015910000390017724500580021626000520027430000210032653301630034787000510051075969419991129184505.0840128s1881
ctu     a     00011 eng dhd-afa014baca  a16-6998//r  a(OCoLC)10350544
9ADH7271AM  aGUAcLWS  aTXAI  aPS15  afilmaBa155110aBurnham,
Clara Louise,d1854-1927.10a"No gentlemen"hmicroform /cby Clara Louise
Burnham.0 aBoston ;aNew York :bHoughton Mifflin,cc1881.  a348 p.
;c18 cm.  aMicrofilm.bWoodbridge, Conn. :cResearch
Publications,d1970-1978.e1 microfilm reel ; 35 mm.f(Wright American
fiction ; v.3 (1876-1900), rel B-81, no. 827)13j100/1aBurnham, Clara
Louise Root,d1854-1927.

Suggestions what that might mean?
Am I doing something wrong in my code?  (As opposed to inefficient, which
I'd also love to hear suggestions on if you have any.)

Thanks,
Mike Barrett
GetSomeFields.pl (application/octet-stream, 1.5 KB)
#! /usr/bin/perl -w
use feature ':5.10';
use strict 'vars';

use MARC::Record;
use MARC::Batch;

my @tags=("1..","24.","6..","7..");	#MARC tags to pull.

my $FileID="0_2";

my $batch= MARC::Batch->new('USMARC',"amdbRepaired".$FileID.".txt");
$batch->strict_off();
$batch->warnings_off();

my $record;
my $bibid;
my $field;

open(OUTPUT,">","SomeFields".$FileID.".txt");
print OUTPUT ("BIB_ID\tTag\tInd\tField\n");
RECORDS: while ($record = $batch->next()){
	#next RECORDS if !defined($record->fields("001"));	#Jump to next record if 001 not found.
	TAGS: foreach my $tag(@tags){
		$bibid=$record->field("001")->as_string;
		foreach $field($record->field($tag)){
			print OUTPUT (
				$bibid,
				"\t",
				$field->tag(),
				"\t",
				defined $field->indicator(1) ? $field->indicator(1) : " ",
				defined $field->indicator(2) ? $field->indicator(2) : " ",
				"\t",
				$field->as_string,"\n"
			)
		}
	}
}

close(OUTPUT);

#Version of decode below courtesy of:  Al  [email protected]
package Encode;
use Encode::Alias;

sub decode($$;$)
{
  my ($name,$octets,$check) = @_;
  my $altstring = $octets;
  return undef unless defined $octets;
  $octets .= '' if ref $octets;
  $check ||=0;
  my $enc = find_encoding($name);
  unless(defined $enc){
     require Carp;
     Carp::croak("Unknown encoding '$name'");
  }
  my $string;
  eval { $string = $enc->decode($octets,$check); };
  $_[1] = $octets if $check and !($check & LEAVE_SRC());
  if ($@) {
     return $altstring;
  } else {
     return $string;
  }
}