From: Dobrica Pavlinusic Date: Fri, 18 May 2007 20:26:01 +0000 (+0000) Subject: added ignore_empty_subfields [0.24_1] X-Git-Url: http://git.rot13.org/?p=Biblio-Isis;a=commitdiff_plain;h=45fa9507148d930eda7cafc89d11dfb332af55e8 added ignore_empty_subfields [0.24_1] git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@70 4670fa4d-42ec-0310-ab5b-a66af6943492 --- diff --git a/lib/Biblio/Isis.pm b/lib/Biblio/Isis.pm index d897400..1e9ffea 100644 --- a/lib/Biblio/Isis.pm +++ b/lib/Biblio/Isis.pm @@ -7,7 +7,7 @@ use File::Glob qw(:globally :nocase); BEGIN { use Exporter (); use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - $VERSION = 0.23; + $VERSION = 0.24_1; @ISA = qw (Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw (); @@ -128,6 +128,10 @@ Define delimiter which will be used to join repeatable subfields. This option is included to support lagacy application written against version older than 0.21 of this module. By default, it disabled. See L. +=item ignore_empty_subfields + +Remove all empty subfields while reading from ISIS file. + =back =cut @@ -139,7 +143,7 @@ sub new { croak "new needs database name (isisdb) as argument!" unless ({@_}->{isisdb}); - foreach my $v (qw{isisdb debug include_deleted hash_filter join_subfields_with}) { + foreach my $v (qw{isisdb debug include_deleted hash_filter join_subfields_with ignore_empty_subfields}) { $self->{$v} = {@_}->{$v} if defined({@_}->{$v}); } @@ -384,7 +388,15 @@ sub fetch { # skip zero-sized fields next if ($FieldLEN[$i] == 0); - push @{$self->{record}->{$FieldTAG[$i]}}, substr($buff,$FieldPOS[$i],$FieldLEN[$i]); + my $v = substr($buff,$FieldPOS[$i],$FieldLEN[$i]); + + if ( $self->{ignore_empty_subfields} ) { + $v =~ s/(\^\w)+(\^\w)/$2/g; + $v =~ s/\^\w$//; # last on line? + next if ($v eq ''); + } + + push @{$self->{record}->{$FieldTAG[$i]}}, $v; } $self->{'current_mfn'} = $mfn; @@ -758,6 +770,10 @@ older versions if you really have to): =over 8 +=item 0.24 + +Added C + =item 0.23 Added C to L