projects
/
webpac2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r730@llin: dpavlin | 2006-06-29 21:33:48 +0200
[webpac2]
/
lib
/
WebPAC
/
Normalize.pm
diff --git
a/lib/WebPAC/Normalize.pm
b/lib/WebPAC/Normalize.pm
index
ea31b37
..
459bb7a
100644
(file)
--- a/
lib/WebPAC/Normalize.pm
+++ b/
lib/WebPAC/Normalize.pm
@@
-17,6
+17,7
@@
use strict;
#use base qw/WebPAC::Common/;
use Data::Dumper;
#use base qw/WebPAC::Common/;
use Data::Dumper;
+use Encode qw/from_to/;
=head1 NAME
=head1 NAME
@@
-24,11
+25,11
@@
WebPAC::Normalize - describe normalisaton rules using sets
=head1 VERSION
=head1 VERSION
-Version 0.0
5
+Version 0.0
6
=cut
=cut
-our $VERSION = '0.0
5
';
+our $VERSION = '0.0
6
';
=head1 SYNOPSIS
=head1 SYNOPSIS
@@
-57,6
+58,7
@@
Return data structure
lookup => $lookup->lookup_hash,
row => $row,
rules => $normalize_pl_config,
lookup => $lookup->lookup_hash,
row => $row,
rules => $normalize_pl_config,
+ marc_encoding => 'utf-8',
);
Options C<lookup>, C<row>, C<rules> and C<log> are mandatory while all
);
Options C<lookup>, C<row>, C<rules> and C<log> are mandatory while all
@@
-78,8
+80,7
@@
sub data_structure {
no strict 'subs';
_set_lookup( $arg->{lookup} );
_set_rec( $arg->{row} );
no strict 'subs';
_set_lookup( $arg->{lookup} );
_set_rec( $arg->{row} );
- _clean_ds();
-
+ _clean_ds( %{ $arg } );
eval "$arg->{rules}";
die "error evaling $arg->{rules}: $@\n" if ($@);
eval "$arg->{rules}";
die "error evaling $arg->{rules}: $@\n" if ($@);
@@
-110,6
+111,7
@@
Return hash formatted as data structure
my $out;
my $marc21;
my $out;
my $marc21;
+my $marc_encoding;
sub _get_ds {
return $out;
sub _get_ds {
return $out;
@@
-124,8
+126,10
@@
Clean data structure hash for next record
=cut
sub _clean_ds {
=cut
sub _clean_ds {
+ my $a = {@_};
$out = undef;
$marc21 = undef;
$out = undef;
$marc21 = undef;
+ $marc_encoding = $a->{marc_encoding};
}
=head2 _set_lookup
}
=head2 _set_lookup
@@
-222,7
+226,10
@@
sub marc21 {
my $sf = shift or die "marc21 needs subfield";
my $sf = shift or die "marc21 needs subfield";
- foreach my $v (@_) {
+ foreach (@_) {
+ my $v = $_; # make var read-write for Encode
+ next unless (defined($v) && $v !~ /^\s+$/);
+ from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding);
push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ];
}
}
push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ];
}
}