use lib instead of blib for local testing
[MARC-Fast] / Fast.pm
diff --git a/Fast.pm b/Fast.pm
index 1178658..aef3d5b 100644 (file)
--- a/Fast.pm
+++ b/Fast.pm
@@ -7,7 +7,7 @@ use Data::Dump qw/dump/;
 BEGIN {
        use Exporter ();
        use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-       $VERSION     = 0.09;
+       $VERSION     = 0.10;
        @ISA         = qw (Exporter);
        #Give a hoot don't pollute, do not export more than needed by default
        @EXPORT      = qw ();
@@ -87,7 +87,8 @@ sub new {
                my $len = read($self->{fh}, $leader, 24);
 
                if ($len < 24) {
-                       carp "short read of leader, aborting\n";
+                       warn "short read of leader, aborting\n";
+                       $self->{count}--;
                        last;
                }
 
@@ -310,14 +311,14 @@ sub to_hash {
 
        my $row = $self->fetch($mfn) || return;
 
-       foreach my $rec_nr (keys %{$row}) {
-               foreach my $l (@{$row->{$rec_nr}}) {
+       foreach my $tag (keys %{$row}) {
+               foreach my $l (@{$row->{$tag}}) {
 
                        # remove end marker
                        $l =~ s/\x1E$//;
 
                        # filter output
-                       $l = $self->{'hash_filter'}->($l, $rec_nr) if ($self->{'hash_filter'});
+                       $l = $self->{'hash_filter'}->($l, $tag) if ($self->{'hash_filter'});
 
                        my $val;
 
@@ -350,7 +351,7 @@ sub to_hash {
                                $val = $l;
                        }
 
-                       push @{$rec->{$rec_nr}}, $val;
+                       push @{$rec->{$tag}}, $val;
                }
        }