'MARC::Record' => '2.0',
'Data::Dump' => 0,
'MARC::Lint' => '1.43',
- # we need as_isbn13
+ # WebPAC::Normalize::ISBN
'Business::ISBN' => '2.02',
'Proc::Queue' => 0,
'PPI' => 0,
+ WebPAC::Output::JSON to produce data for Simile's exhibit
+ leader from WebPAC::Input::MARC is now available as rec('leader')
+ show i1 and i2 in statistcs specially (sorted first)
++ ISBN support in normalize
- indicator(field,nr) nr=1|2 for MARC input
- check usage of config in normalize file (database, input name?)
- load_ds/save_ds should use on-disk hash to preserve inodes
--- /dev/null
+package WebPAC::Normalize::ISBN;
+use Exporter 'import';
+@EXPORT = qw/
+ isbn_13
+ isbn_10
+/;
+
+use warnings;
+use strict;
+
+use Data::Dump qw/dump/;
+use Carp qw/confess/;
+
+use Business::ISBN;
+
+my $debug = 0;
+
+=head1 NAME
+
+WebPAC::Normalize::ISBN - work with ISBN numbers
+
+=cut
+
+=head1 FUNCTIONS
+
+=head2 isbn_13
+
+ my @isbns = isbn_13( rec('10') );
+
+=cut
+
+sub isbn_13 {
+ my @out;
+
+ foreach my $isbn ( @_ ) {
+
+ my $i = Business::ISBN->new( $isbn );
+ if ( ! $i ) {
+ warn "ERROR: ISBN not valid: $isbn\n";
+ } else {
+ push @out, $i->as_isbn13->as_string;
+ }
+ }
+
+ warn "### isbn13",dump( @_ )," => ",dump( @out ) if $debug;
+
+ return @out;
+}
+
+=head2 isbn_10
+
+ my @isbns = isbn_10( rec('10') );
+
+=cut
+
+sub isbn_10 {
+ my @out;
+
+ foreach my $isbn ( @_ ) {
+
+ my $i = Business::ISBN->new( $isbn );
+ if ( ! $i ) {
+ warn "ERROR: ISBN not valid: $isbn\n";
+ } else {
+ push @out, $i->as_isbn10->as_string;
+ }
+ }
+
+ warn "### isbn10",dump( @_ )," => ",dump( @out ) if $debug;
+
+ return @out;
+}
+
+1;
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use blib;
+
+use Test::More tests => 4;
+
+BEGIN {
+ use_ok( 'WebPAC::Test' );
+ use_ok( 'WebPAC::Normalize::ISBN' );
+}
+
+is_deeply(
+ [ isbn_13( '1558607013', '978-1558607019' ) ],
+ [ '978-1-55860-701-9', '978-1-55860-701-9', ],
+'isbn_13' );
+
+is_deeply(
+ [ isbn_10( '1558607013', '978-1558607019' ) ],
+ [ '1-55860-701-3', '1-55860-701-3' ],
+'isbn_10' );