X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=Equinox-Migration%2Flib%2FEquinox%2FMigration%2FMARCXMLSampler.pm;h=1cd8b5c0dddc34b6c0818a6e5b58d2c1f9ae2f51;hp=e4243e694a1458d3df704eb96c3cad9a87b46411;hb=1c8c72dc5c4f99e6eacd61c4ddbf96e835a79cf1;hpb=5cb143f1fc584a55e4732dbc747c875367baa241 diff --git a/Equinox-Migration/lib/Equinox/Migration/MARCXMLSampler.pm b/Equinox-Migration/lib/Equinox/Migration/MARCXMLSampler.pm index e4243e6..1cd8b5c 100644 --- a/Equinox-Migration/lib/Equinox/Migration/MARCXMLSampler.pm +++ b/Equinox-Migration/lib/Equinox/Migration/MARCXMLSampler.pm @@ -13,11 +13,11 @@ Equinox::Migration::MARCXMLSampler =head1 VERSION -Version 1.000 +Version 1.002 =cut -our $VERSION = '1.000'; +our $VERSION = '1.002'; =head1 SYNOPSIS @@ -63,6 +63,7 @@ sub new { my $self = bless { data => { recs => undef, # X::T record objects rcnt => 0, # record counter tcnt => 0, # tag counter + scnt => {}, # subfield/tag counters samp => {}, # data samples tags => {}, # all found tags }, @@ -122,8 +123,12 @@ sub process_field { if ($map and $map->has($tag)) { my @subs = $field->children('subfield'); + my $i= 0; for my $sub (@subs) - { $self->process_subs($tag, $sub); $sub->purge } + { $self->process_subs($tag, $sub); $sub->purge; $i++ } + + # increment sub length counter + $self->{data}{scnt}{$tag}{$i}++; } } @@ -135,12 +140,11 @@ sub process_subs { # handle unmapped tag/subs my $samp = $self->{data}{samp}; # set a value, total-seen count and records-seen-in count - $samp->{$tag}{$code}{value} = $sub->text unless defined $samp->{$tag}{$code}; + $samp->{$tag}{$code}{value} = $sub->text unless $samp->{$tag}{$code}; $samp->{$tag}{$code}{count}++; $samp->{$tag}{$code}{tcnt}++ unless ( defined $samp->{$tag}{$code}{last} and $samp->{$tag}{$code}{last} == $self->{data}{tcnt} ); $samp->{$tag}{$code}{last} = $self->{data}{tcnt}; - #FIXME tcnt not rcnt }