diff options
author | Yorhel <git@yorhel.nl> | 2010-11-03 11:04:22 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2010-11-03 11:06:02 +0100 |
commit | bb3f32e88166fad0c1a5bad5762f2618eeed6437 (patch) | |
tree | 3855d9585a3b0ebd5a77d429a0d9e816c7a838a8 /lib/VNDBUtil.pm | |
parent | 97eb068a5f6b3a6e3c10ffc4f7230bf2342b3102 (diff) | |
parent | f72772a0e741399e2fcb3b83f54d0d8ac52b4d2c (diff) |
Merge branch 'master' into beta
Conflicts:
lib/VNDB/DB/VN.pm
lib/VNDB/Func.pm
Diffstat (limited to 'lib/VNDBUtil.pm')
-rw-r--r-- | lib/VNDBUtil.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm index 48b5f01b..bda54383 100644 --- a/lib/VNDBUtil.pm +++ b/lib/VNDBUtil.pm @@ -134,10 +134,10 @@ sub bb2html { # Also 'normalizes' the first argument in place sub gtintype { $_[0] =~ s/[^\d]+//g; - $_[0] =~ s/^0+//; + $_[0] = ('0'x(12-length $_[0])) . $_[0] if length($_[0]) < 12; # pad with zeros to GTIN-12 my $c = shift; - return undef if $c !~ /^[0-9]{12,13}$/; # only gtin-12 and 13 - $c = ('0'x(13-length $c)) . $c; # pad with zeros + return undef if $c !~ /^[0-9]{12,13}$/; + $c = "0$c" if length($c) == 12; # pad with another zero for GTIN-13 # calculate check digit according to # http://www.gs1.org/productssolutions/barcodes/support/check_digit_calculator.html#how @@ -152,7 +152,7 @@ sub gtintype { local $_ = $c; return 'JAN' if /^4[59]/; # prefix code 450-459 & 490-499 return 'UPC' if /^(?:0[01]|0[6-9]|13|75[45])/; # prefix code 000-019 & 060-139 & 754-755 - return undef if /(?:0[2-5]|2|97[789]|9[6-9])/; # some codes we don't want: 020–059 & 200-299 & 977-999 + return undef if /^(?:0[2-5]|2|97[789]|9[6-9])/; # some codes we don't want: 020–059 & 200-299 & 977-999 return 'EAN'; # let's just call everything else EAN :) } |