# Why drop the nonzero digit after the T?
# Why pass non-digits (or empty string) to "T%07d"?
} elsif ($filter eq 'EAN13') {
+ $barcode = sprintf('%013d',$barcode);
my $ean = CheckDigits('ean');
- if ( $ean->is_valid($barcode) ) {
- if ( length($barcode) == 12 ) {
- # upgrade UPC-A to EAN-13
- $barcode = '0' . $barcode;
- }
+ if ( ! $ean->is_valid($barcode) ) {
+ warn "[$barcode] not valid EAN-13/UPC-A";
}
- return "$barcode - not valid EAN-13/UPC-A"; # XXX comment-out to disable
}
return $barcode; # return barcode, modified or not
}
my $ean = CheckDigits('ean');
if ( $ean->is_valid($nextnum) ) {
my $next = $ean->basenumber( $nextnum ) + 1;
- $nextnum = $ean->complete( $next );
+ $nextnum = sprintf('%013d',$ean->complete( $next ));
} else {
warn "ERROR: invalid EAN-13 $nextnum, using increment";
$nextnum++;