| 1 | package Barcode::Cuecat; | ||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||
| 3 | 1 | require 5.005_62; | |||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '1.20'; | |||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||
| 10 | 0 | my $type = shift; | |||||||||||||||||||||||
| 11 | 0 | ▶ | my $class = ref($type) || $type || "Barcode::Cuecat"; | ||||||||||||||||||||||
|
Condition0%0/5
ref $type || $type || 'Barcode::Cuecat'
ref $type or $type
MC/DC0%0/2
ref $type || $type || 'Barcode::Cuecat'
ref $type
$type
Truth table0%0/3
A or B
A= ref $typeB= $type
| |||||||||||||||||||||||||
| 12 | 0 | my $string = shift; | |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||
| 14 | 0 | my $self = bless [], $class; | |||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||
| 16 | 0 | ▶ | $self->scan($string) if defined $string; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||
| 18 | 0 | return $self; | |||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||
| 21 | 0 | ▶ | sub _decode { | ||||||||||||||||||||||
|
Subroutine
_decode: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 22 | 0 | my $input = shift; | |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||
| 24 | 0 | $input =~ tr/a-zA-Z0-9+-/ -_/; | |||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||
| 26 | 0 | $input = unpack 'u', chr(32 + length($input)*3/4) . $input; | |||||||||||||||||||||||
| 27 | 0 | $input ^= "C" x length($input); | |||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||
| 29 | 0 | return $input; | |||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||
| 32 | 0 | ▶ | sub _cuecat_decode { | ||||||||||||||||||||||
|
Subroutine
_cuecat_decode: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 33 | 0 | my $input = shift; | |||||||||||||||||||||||
| 34 | 0 | $input ^= chr(32) x length($input); | |||||||||||||||||||||||
| 35 | return join '', map { | ||||||||||||||||||||||||
| 36 | 0 | $_ = sprintf("%02d", ord($_)); | |||||||||||||||||||||||
| 37 | } split(//, $input); | ||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||
| 40 | 0 | ▶ | sub scan ($) { | ||||||||||||||||||||||
|
Subroutine
scan: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||||||
| 42 | 0 | my $stuff = shift; | |||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||
| 44 | 0 | ▶ | return unless defined $stuff; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||
| 46 | 0 | my @items = (split(/\./, $stuff))[1..3]; | |||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||
| 48 | 0 | $self->[0] = _decode($items[0]); | |||||||||||||||||||||||
| 49 | 0 | $self->[1] = _decode($items[1]); | |||||||||||||||||||||||
| 50 | 0 | $self->[2] = _decode($items[2]); | |||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($self->[1] =~ /^CC(.)/) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 53 | 0 | $self->[1] = ':C1'; # Proprietary :CueCat | |||||||||||||||||||||||
| 54 | 0 | $self->[2] = _cuecat_decode($1 . $self->[2]); | |||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||
| 57 | 0 | return $self->[2]; | |||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||
| 60 | 0 | ▶ | sub serial { | ||||||||||||||||||||||
|
Subroutine
serial: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 61 | 0 | return $_[0]->[0]; | |||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||
| 64 | 0 | ▶ | sub type { | ||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 65 | 0 | return $_[0]->[1]; | |||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||
| 68 | 0 | ▶ | sub code { | ||||||||||||||||||||||
|
Subroutine
code: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 69 | 0 | return $_[0]->[2]; | |||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||
| 72 | 1 | 1; | |||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||