/[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 960 - (show annotations)
Fri Nov 2 11:32:02 2007 UTC (16 years, 6 months ago) by dpavlin
File size: 990 byte(s)
 r1462@llin:  dpavlin | 2007-11-02 12:31:57 +0100
 ISBN support in normalization using isbn_10 and isbn_13

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 my $i = Business::ISBN->new( $isbn );
38 if ( ! $i ) {
39 warn "ERROR: ISBN not valid: $isbn\n";
40 } else {
41 push @out, $i->as_isbn13->as_string;
42 }
43 }
44
45 warn "### isbn13",dump( @_ )," => ",dump( @out ) if $debug;
46
47 return @out;
48 }
49
50 =head2 isbn_10
51
52 my @isbns = isbn_10( rec('10') );
53
54 =cut
55
56 sub isbn_10 {
57 my @out;
58
59 foreach my $isbn ( @_ ) {
60
61 my $i = Business::ISBN->new( $isbn );
62 if ( ! $i ) {
63 warn "ERROR: ISBN not valid: $isbn\n";
64 } else {
65 push @out, $i->as_isbn10->as_string;
66 }
67 }
68
69 warn "### isbn10",dump( @_ )," => ",dump( @out ) if $debug;
70
71 return @out;
72 }
73
74 1;

  ViewVC Help
Powered by ViewVC 1.1.26