=head1 VERSION
-Version 0.03
+Version 0.04
=cut
-our $VERSION = '0.03';
+our $VERSION = '0.04';
=head1 SYNOPSIS
);
$db->open('/path/to/database');
- print "database size: ",$db->size,"\n";
- while (my $rec = $db->fetch) {
- }
+ print "database size: ",$db->size,"\n";
+ while (my $rec = $db->fetch) {
+ # do something with $rec
+ }
module => 'WebPAC::Input::MARC',
code_page => 'ISO-8859-2',
low_mem => 1,
+ recode => 'char pairs',
);
C<module> is low-level file format module. See L<WebPAC::Input::Isis> and
# create Text::Iconv object
$self->{iconv} = Text::Iconv->new($code_page,$self->{'code_page'});
+ my $filter_ref;
+
+ if ($self->{recode}) {
+ my @r = split(/\s/, $self->{recode});
+ if ($#r % 2 != 1) {
+ $log->logwarn("recode needs even number of elements (some number of valid pairs)");
+ } else {
+ my $recode;
+ while (@r) {
+ my $from = shift @r;
+ my $to = shift @r;
+ $recode->{$from} = $to;
+ }
+
+ my $regex = join '|' => keys %{ $recode };
+
+ $log->debug("using recode regex: $regex");
+
+ $filter_ref = sub {
+ my $t = shift;
+ $t =~ s/($regex)/$recode->{$1}/g;
+ return $t;
+ };
+
+ }
+
+ }
+
my ($db, $size) = $self->{open_db}->( $self,
path => $arg->{path},
+ filter => $filter_ref,
);
unless ($db) {
use warnings;
use strict;
-use MARC::Fast;
+use MARC::Fast 0.03;
=head1 NAME
=head1 VERSION
-Version 0.04
+Version 0.05
=cut
-our $VERSION = '0.04';
+our $VERSION = '0.05';
=head1 SYNOPSIS
Returns handle to database
my $db = $open_db(
- path => '/path/to/marc.iso'
+ path => '/path/to/marc.iso',
+ filter => \&code_ref,
}
=cut
$log->info("opening MARC database '$arg->{path}'");
- my $db = new MARC::Fast( marcdb => $arg->{path});
+ my $db = new MARC::Fast(
+ marcdb => $arg->{path},
+ hash_filter => $arg->{filter},
+ );
my $db_size = $db->count - 1; # FIXME
$self->{_marc_size} = $db_size;
limit => $limit || $input->{limit},
offset => $offset,
lookup => $lookup,
+ recode => $input->{recode},
);
$log->logdie("can't create input using $input_module") unless ($input);