line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
193
|
use 5.008; |
|
8
|
|
|
|
|
46
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Business::ISBN10; |
4
|
8
|
|
|
8
|
|
59
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
246
|
|
5
|
8
|
|
|
8
|
|
44
|
use base qw(Business::ISBN); |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
1137
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
56
|
use Business::ISBN qw(:all); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
1519
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
|
|
433
|
use vars qw( |
10
|
|
|
|
|
|
|
$MAX_GROUP_CODE_LENGTH |
11
|
|
|
|
|
|
|
%ERROR_TEXT |
12
|
8
|
|
|
8
|
|
53
|
); |
|
8
|
|
|
|
|
87
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
48
|
use Carp qw(carp croak cluck); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
3046
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $debug = 0; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '3.007'; |
19
|
|
|
|
|
|
|
|
20
|
106641
|
|
|
106641
|
|
216553
|
sub _max_length { 10 } |
21
|
|
|
|
|
|
|
|
22
|
106643
|
|
|
106643
|
|
225498
|
sub _set_type { $_[0]->{type} = 'ISBN10' } |
23
|
|
|
|
|
|
|
|
24
|
106643
|
|
|
106643
|
|
177999
|
sub _parse_prefix { '' } |
25
|
|
|
|
|
|
|
sub _set_prefix { |
26
|
106644
|
100
|
|
106644
|
|
189348
|
croak "Cannot set prefix [$_[1]] on an ISBN-10" if length $_[1]; |
27
|
|
|
|
|
|
|
|
28
|
106643
|
|
|
|
|
249324
|
$_[0]->{prefix} = $_[1]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _hyphen_positions { |
32
|
|
|
|
|
|
|
[ |
33
|
3
|
|
|
3
|
|
13
|
$_[0]->_group_code_length, |
34
|
|
|
|
|
|
|
$_[0]->_group_code_length + $_[0]->_publisher_code_length, |
35
|
|
|
|
|
|
|
9 |
36
|
|
|
|
|
|
|
] |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub as_isbn10 { |
40
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
my $isbn10 = Business::ISBN->new( $self->isbn ); |
43
|
1
|
|
|
|
|
7
|
$isbn10->fix_checksum; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
return $isbn10; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub as_isbn13 { |
49
|
2
|
|
|
2
|
1
|
471
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
5
|
my $isbn13 = Business::ISBN->new( '978' . $self->isbn ); |
52
|
2
|
|
|
|
|
7
|
$isbn13->fix_checksum; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
5
|
return $isbn13; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#internal function. you don't get to use this one. |
58
|
|
|
|
|
|
|
sub _checksum { |
59
|
106649
|
|
|
106649
|
|
198721
|
my $data = $_[0]->isbn; |
60
|
|
|
|
|
|
|
|
61
|
106649
|
50
|
|
|
|
196076
|
return unless defined $data; |
62
|
|
|
|
|
|
|
|
63
|
106649
|
|
|
|
|
312834
|
my @digits = split //, $data; |
64
|
106649
|
|
|
|
|
134553
|
my $sum = 0; |
65
|
|
|
|
|
|
|
|
66
|
106649
|
|
|
|
|
186835
|
foreach( reverse 2..10 ) { |
67
|
959841
|
|
|
|
|
1454760
|
$sum += $_ * (shift @digits); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#return what the check digit should be |
71
|
106649
|
|
|
|
|
174490
|
my $checksum = (11 - ($sum % 11))%11; |
72
|
|
|
|
|
|
|
|
73
|
106649
|
100
|
|
|
|
182742
|
$checksum = 'X' if $checksum == 10; |
74
|
|
|
|
|
|
|
|
75
|
106649
|
|
|
|
|
456449
|
return $checksum; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |