1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
package Catmandu::Fix::isbn10;
our $VERSION = '0.15';
use Catmandu::Sane;
use Business::ISBN;
use Moo;
use Catmandu::Fix::Has;
has path => (fix_arg => 1);
with 'Catmandu::Fix::SimpleGetValue';
sub emit_value {
my ($self, $var) = @_;
qq|
if (is_value(${var}) && length(${var})) {
my \$isbn10 = Business::ISBN->new(${var})->as_isbn10;
${var} = \$isbn10 ? \$isbn10->as_string : '';
}
|;
}
=head1 NAME
Catmandu::Fix::isbn10 - normalize the isbn value of a key in 10-digit form
=head1 SYNOPSIS
# Normalize the ISBN value of isbn_field.
# e.g. isbn_field => '1565922573'
isbn10(isbn_field) # isbn_field => '1-56592-257-3'
=head1 SEE ALSO
L<Catmandu::Fix>, L<Catmandu::Fix::isbn13>
=cut
1;
|