1 package URI::urn::isbn; # RFC 3187
10 require Business::ISBN;
12 local $^W = 0; # don't warn about dev versions, perl5.004 style
13 warn "Using Business::ISBN version " . Business::ISBN->VERSION .
14 " which is deprecated.\nUpgrade to Business::ISBN version 2\n"
15 if Business::ISBN->VERSION < 2;
20 $nss = $nss->nss if ref($nss);
21 my $isbn = Business::ISBN->new($nss);
22 $isbn = undef if $isbn && !$isbn->is_valid;
28 my $nss = $self->nss(@_);
29 my $isbn = _isbn($nss);
30 $isbn = $isbn->as_string if $isbn;
37 (undef, $isbn) = $self->_nss_isbn(@_);
41 sub isbn_publisher_code {
42 my $isbn = shift->_isbn || return undef;
43 return $isbn->publisher_code;
47 my $group_method = do {
48 local $^W = 0; # don't warn about dev versions, perl5.004 style
49 Business::ISBN->VERSION >= 2 ? 'group_code' : 'country_code';
53 my $isbn = shift->_isbn || return undef;
54 return $isbn->$group_method;
58 sub isbn_country_code {
59 my $name = (caller(0))[3]; $name =~ s/.*:://;
60 carp "$name is DEPRECATED. Use isbn_group_code instead";
67 my $isbn13_method = do {
68 local $^W = 0; # don't warn about dev versions, perl5.004 style
69 Business::ISBN->VERSION >= 2 ? 'as_isbn13' : 'as_ean';
73 my $isbn = shift->_isbn || return undef;
75 # Business::ISBN 1.x didn't put hyphens in the EAN, and it was just a string
76 # Business::ISBN 2.0 doesn't do EAN, but it does ISBN-13 objects
77 # and it uses the hyphens, so call as_string with an empty anon array
78 # or, adjust the test and features to say that it comes out with hyphens.
79 my $thingy = $isbn->$isbn13_method;
80 return eval { $thingy->can( 'as_string' ) } ? $thingy->as_string([]) : $thingy;
85 my $name = (caller(0))[3]; $name =~ s/.*:://;
86 carp "$name is DEPRECATED. Use isbn13 instead";
94 my($nss, $isbn) = $self->_nss_isbn;
95 my $new = $self->SUPER::canonical;
96 return $new unless $nss && $isbn && $nss ne $isbn;
97 $new = $new->clone if $new == $self;