Use the ISBN Object's method to format the string
rather than add extra code to do it
Clean up the code flow for clarity
Benchmarking shows its a bit faster too
Don't add to the number of Test::Perl::Critic warnings
for no benefit
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
return $normalized_match_point;
}
-sub _isbn_cleanup ($) {
- my $isbn = Business::ISBN->new( shift );
- return undef unless $isbn;
- $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
- return undef unless $isbn;
- $isbn = $isbn->as_string;
- $isbn =~ s/-//g;
- return $isbn;
+sub _isbn_cleanup {
+ my $isbn = Business::ISBN->new( $_[0] );
+ if ( $isbn ) {
+ $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
+ if (defined $isbn) {
+ return $isbn->as_string([]);
+ }
+ }
+ return;
}
1;