line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
166
|
use 5.008; |
|
8
|
|
|
|
|
31
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Business::ISBN10; |
4
|
8
|
|
|
8
|
|
52
|
use strict; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
242
|
|
5
|
8
|
|
|
8
|
|
49
|
use base qw(Business::ISBN); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
1118
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
58
|
use Business::ISBN qw(:all); |
|
8
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
1533
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
|
|
431
|
use vars qw( |
10
|
|
|
|
|
|
|
$MAX_GROUP_CODE_LENGTH |
11
|
|
|
|
|
|
|
%ERROR_TEXT |
12
|
8
|
|
|
8
|
|
54
|
); |
|
8
|
|
|
|
|
91
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
47
|
use Carp qw(carp croak cluck); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
3106
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $debug = 0; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '3.006'; |
19
|
|
|
|
|
|
|
|
20
|
106641
|
|
|
106641
|
|
219613
|
sub _max_length { 10 } |
21
|
|
|
|
|
|
|
|
22
|
106643
|
|
|
106643
|
|
235821
|
sub _set_type { $_[0]->{type} = 'ISBN10' } |
23
|
|
|
|
|
|
|
|
24
|
106643
|
|
|
106643
|
|
200930
|
sub _parse_prefix { '' } |
25
|
|
|
|
|
|
|
sub _set_prefix { |
26
|
106644
|
100
|
|
106644
|
|
213369
|
croak "Cannot set prefix [$_[1]] on an ISBN-10" if length $_[1]; |
27
|
|
|
|
|
|
|
|
28
|
106643
|
|
|
|
|
255275
|
$_[0]->{prefix} = $_[1]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _hyphen_positions { |
32
|
|
|
|
|
|
|
[ |
33
|
3
|
|
|
3
|
|
12
|
$_[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
|
2
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
5
|
my $isbn10 = Business::ISBN->new( $self->isbn ); |
43
|
1
|
|
|
|
|
24
|
$isbn10->fix_checksum; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
3
|
return $isbn10; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub as_isbn13 { |
49
|
2
|
|
|
2
|
1
|
543
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
6
|
my $isbn13 = Business::ISBN->new( '978' . $self->isbn ); |
52
|
2
|
|
|
|
|
9
|
$isbn13->fix_checksum; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
7
|
return $isbn13; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#internal function. you don't get to use this one. |
58
|
|
|
|
|
|
|
sub _checksum { |
59
|
106649
|
|
|
106649
|
|
206297
|
my $data = $_[0]->isbn; |
60
|
|
|
|
|
|
|
|
61
|
106649
|
50
|
|
|
|
201210
|
return unless defined $data; |
62
|
|
|
|
|
|
|
|
63
|
106649
|
|
|
|
|
314535
|
my @digits = split //, $data; |
64
|
106649
|
|
|
|
|
141763
|
my $sum = 0; |
65
|
|
|
|
|
|
|
|
66
|
106649
|
|
|
|
|
188830
|
foreach( reverse 2..10 ) { |
67
|
959841
|
|
|
|
|
1508323
|
$sum += $_ * (shift @digits); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#return what the check digit should be |
71
|
106649
|
|
|
|
|
184160
|
my $checksum = (11 - ($sum % 11))%11; |
72
|
|
|
|
|
|
|
|
73
|
106649
|
100
|
|
|
|
201168
|
$checksum = 'X' if $checksum == 10; |
74
|
|
|
|
|
|
|
|
75
|
106649
|
|
|
|
|
462942
|
return $checksum; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |