line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::isbn_versions; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
87977
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
159018
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
822
|
use Business::ISBN; |
|
1
|
|
|
|
|
31335
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
754
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
817
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::SimpleGetValue'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub emit_value { |
15
|
3
|
|
|
3
|
0
|
14025
|
my ($self, $var) = @_; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
17
|
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; |