documented hash_filter, fully implemented repeatable subfileds. [0.03]
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 28 Dec 2005 22:16:39 +0000 (22:16 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 28 Dec 2005 22:16:39 +0000 (22:16 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/MARC-Fast/trunk@8 49f9634a-d7ec-0310-8e6b-ec35c6cc8804

Changes
Fast.pm

diff --git a/Changes b/Changes
index be97c42..d51fb61 100644 (file)
--- a/Changes
+++ b/Changes
@@ -7,3 +7,6 @@ Revision history for Perl module MARC::Fast
        - convert repeatable fileds into repeatable subfields
          900^afoo and 900^abar -> 900^afoo^abar
 
        - convert repeatable fileds into repeatable subfields
          900^afoo and 900^abar -> 900^afoo^abar
 
+0.03 Wed Dec 28 23:13:29 CET 2005
+       - really fixed repeatable subfields
+       - much nicer script/dump_fastmarc.pl with it's own POD
diff --git a/Fast.pm b/Fast.pm
index 6116b14..7f2a618 100644 (file)
--- a/Fast.pm
+++ b/Fast.pm
@@ -7,7 +7,7 @@ use Data::Dumper;
 BEGIN {
        use Exporter ();
        use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 BEGIN {
        use Exporter ();
        use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-       $VERSION     = 0.02;
+       $VERSION     = 0.03;
        @ISA         = qw (Exporter);
        #Give a hoot don't pollute, do not export more than needed by default
        @EXPORT      = qw ();
        @ISA         = qw (Exporter);
        #Give a hoot don't pollute, do not export more than needed by default
        @EXPORT      = qw ();
@@ -42,6 +42,11 @@ Read MARC database
        quiet => 0,
        debug => 0,
        assert => 0,
        quiet => 0,
        debug => 0,
        assert => 0,
+       hash_filter => sub {
+               my $t = shift;
+               $t =~ s/foo/bar/;
+               return $t;
+       },
   );
 
 =cut
   );
 
 =cut
@@ -283,6 +288,18 @@ sub to_hash {
                        if ($l =~ m/\x1F/) {
                                foreach my $t (split(/\x1F/,$l)) {
                                        next if (! $t);
                        if ($l =~ m/\x1F/) {
                                foreach my $t (split(/\x1F/,$l)) {
                                        next if (! $t);
+                                       my $f = substr($t,0,1);
+                                       # repeatable subfileds. When we hit first one,
+                                       # store CURRENT (up to that) in first repetition
+                                       # of this record. Then, new record with same
+                                       # identifiers will be created.
+                                       if ($val->{$f}) {
+                                               push @{$rec->{$k}}, $val;
+                                               $val = {
+                                                       i1 => $val->{i1},
+                                                       i2 => $val->{i2},
+                                               };
+                                       }
                                        $val->{substr($t,0,1)} = substr($t,1);
                                }
                        } else {
                                        $val->{substr($t,0,1)} = substr($t,1);
                                }
                        } else {