/[webpac2]/trunk/lib/WebPAC/Normalize/ISBN.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/WebPAC/Normalize/ISBN.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1004 - (show annotations)
Sun Nov 4 19:02:54 2007 UTC (16 years, 5 months ago) by dpavlin
File size: 1052 byte(s)
 r1548@llin:  dpavlin | 2007-11-04 20:02:54 +0100
 ignore ISBNs with numbers (empty or invalid)

1 package WebPAC::Normalize::ISBN;
2 use Exporter 'import';
3 @EXPORT = qw/
4 isbn_13
5 isbn_10
6 /;
7
8 use warnings;
9 use strict;
10
11 use Data::Dump qw/dump/;
12 use Carp qw/confess/;
13
14 use Business::ISBN;
15
16 my $debug = 0;
17
18 =head1 NAME
19
20 WebPAC::Normalize::ISBN - work with ISBN numbers
21
22 =cut
23
24 =head1 FUNCTIONS
25
26 =head2 isbn_13
27
28 my @isbns = isbn_13( rec('10') );
29
30 =cut
31
32 sub isbn_13 {
33 my @out;
34
35 foreach my $isbn ( @_ ) {
36
37 next unless $isbn =~ m/\d/;
38
39 my $i = Business::ISBN->new( $isbn );
40 if ( ! $i ) {
41 warn "ERROR: ISBN not valid: $isbn\n";
42 } else {
43 push @out, $i->as_isbn13->as_string;
44 }
45 }
46
47 warn "### isbn13",dump( @_ )," => ",dump( @out ) if $debug;
48
49 return @out;
50 }
51
52 =head2 isbn_10
53
54 my @isbns = isbn_10( rec('10') );
55
56 =cut
57
58 sub isbn_10 {
59 my @out;
60
61 foreach my $isbn ( @_ ) {
62
63 next unless $isbn =~ m/\d/;
64
65 my $i = Business::ISBN->new( $isbn );
66 if ( ! $i ) {
67 warn "ERROR: ISBN not valid: $isbn\n";
68 } else {
69 push @out, $i->as_isbn10->as_string;
70 }
71 }
72
73 warn "### isbn10",dump( @_ )," => ",dump( @out ) if $debug;
74
75 return @out;
76 }
77
78 1;

  ViewVC Help
Powered by ViewVC 1.1.26