line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::isbn_versions; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
104548
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
190300
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
816
|
use Business::ISBN; |
|
1
|
|
|
|
|
43379
|
|
|
1
|
|
|
|
|
51
|
|
7
|
1
|
|
|
1
|
|
9
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
1
|
|
|
1
|
|
898
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
983
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::SimpleGetValue'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub emit_value { |
15
|
2
|
|
|
2
|
0
|
11661
|
my ($self, $var) = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
13
|
qq| |
18
|
|
|
|
|
|
|
if (is_value(${var}) && length(${var})) { |
19
|
|
|
|
|
|
|
my \$val = ${var}; |
20
|
|
|
|
|
|
|
\$val =~ s/\\s.*//; |
21
|
|
|
|
|
|
|
my \$isbn = Business::ISBN->new(\$val); |
22
|
|
|
|
|
|
|
if (defined \$isbn && \$isbn->is_valid) { |
23
|
|
|
|
|
|
|
my \$isbn13 = \$isbn->as_isbn13->as_string; |
24
|
|
|
|
|
|
|
my \$isbn13d = \$isbn13; |
25
|
|
|
|
|
|
|
\$isbn13d =~ s/\-//g; |
26
|
|
|
|
|
|
|
my \$isbn10 = \$isbn->as_isbn10; |
27
|
|
|
|
|
|
|
if (\$isbn10) { |
28
|
|
|
|
|
|
|
my \$isbn10d = \$isbn10->as_string; |
29
|
|
|
|
|
|
|
\$isbn10d =~ s/\-//g; |
30
|
|
|
|
|
|
|
${var} = [\$isbn10->as_string, \$isbn10d, \$isbn13, \$isbn13d]; |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
${var} = [(\$isbn13, \$isbn13d)]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Catmandu::Fix::isbn_versions - provide different forms for an ISBN |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Convert any given ISBN to ISBN-13 and ISBN-10 (if possible) with and without dashes. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SEE ALSO |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L<Catmandu::Fix>, L<Catmandu::Fix::isbn10>, L<Catmandu::Fix::isbn13> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |