--- trunk/lib/WebPAC/Normalize.pm 2006/12/10 12:45:11 786 +++ trunk/lib/WebPAC/Normalize.pm 2007/04/01 21:47:42 812 @@ -21,6 +21,7 @@ split_rec_on get set + count /; use warnings; @@ -41,11 +42,11 @@ =head1 VERSION -Version 0.25 +Version 0.26 =cut -our $VERSION = '0.25'; +our $VERSION = '0.26'; =head1 SYNOPSIS @@ -166,7 +167,7 @@ =cut -my ($out, $marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $leader); +my ($out, $marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader); my ($marc_record_offset, $marc_fetch_offset) = (0, 0); sub _get_ds { @@ -183,7 +184,7 @@ sub _clean_ds { my $a = {@_}; - ($out,$marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $leader) = (); + ($out,$marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader) = (); ($marc_record_offset, $marc_fetch_offset) = (0,0); $marc_encoding = $a->{marc_encoding}; } @@ -489,9 +490,9 @@ my ($offset,$value) = @_; if ($offset) { - $leader->{ $offset } = $value; + $marc_leader->{ $offset } = $value; } else { - return $leader; + return $marc_leader; } } @@ -661,6 +662,7 @@ if ($f eq '*') { delete( $marc_record->[ $marc_record_offset ] ); + warn "## full marc_record = ", dump( @{ $marc_record }), $/ if ($debug > 1); } else { @@ -699,7 +701,6 @@ $marc_record->[ $marc_record_offset ] = $marc; } - warn "## full marc_record = ", dump( @{ $marc_record }), $/ if ($debug > 1); } @@ -1272,7 +1273,7 @@ sub set { my ($k,$v) = @_; - warn "## set ( $k => ", dump($v), " )", $/; + warn "## set ( $k => ", dump($v), " )", $/ if ( $debug ); $hash->{$k} = $v; }; @@ -1285,10 +1286,22 @@ sub get { my $k = shift || return; my $v = $hash->{$k}; - warn "## get $k = ", dump( $v ), $/; + warn "## get $k = ", dump( $v ), $/ if ( $debug ); return $v; } +=head2 count + + if ( count( @result ) == 1 ) { + # do something if only 1 result is there + } + +=cut + +sub count { + warn "## count ",dump(@_),$/ if ( $debug ); + return @_ . ''; +} # END 1;