NAME
Data::URIID::Barcode - Extractor for identifiers from URIs
VERSION
version v0.15
SYNOPSIS
use Data::URIID::Barcode;
my Data::URIID::Barcode $barcode = Data::URIID::Barcode->new(type => ..., data => ..., [ %opts ] );
# or:
my Data::URIID::Barcode $barcode = Data::URIID::Barcode->new(from => ..., [ %opts ] );
This module represents a single barcode.
This package inherits from Data::URIID::Base.
METHODS
sheet
my @barcodes = Data::URIID::Barcode->sheet(%opts);
# or:
my $barcode = Data::URIID::Barcode->sheet(%opts);
# e.g.:
my @barcodes = Data::URIID::Barcode->sheet(filename => 'bla.jpg');
# or:
my @barcodes = Data::URIID::Barcode->sheet(type => Data::URIID::Barcode->TYPE_QRCODE, template => 'IDX-%03u', values => [0 .. 9]);
Creates a set of barcode objects from a sheet.
When called in scalar context returns the best result (best for a metric not further defined, which may also change in later versions) or die
s if none was found.
Experimental: This method is currently experimental. It might change at any time.
The following options are supported:
filename
-
A file to read from.
from
-
A perl object to use. If given
values
must beundef
. values
-
A list (arrayref) of values to be used as data barcodes to be generated. If given
from
must beundef
. template
-
A template (see "sprintf" in perlfunc) that is applied to each value in
values
.Defaults to no transformation. If defined, must not be used with values that are references.
new
my Data::URIID::Barcode $barcode = Data::URIID::Barcode->new(type => ..., data => ..., [ %opts ] );
# or:
my Data::URIID::Barcode $barcode = Data::URIID::Barcode->new(from => ..., [ %opts ] );
This method creates a new barcode object.
The following options are supported:
data
-
The raw data of the barcode.
extractor
-
optionally, an instance of Data::URIID.
from
-
optionally, an instance of another object to read the values from. Depending on the given object the non-optional values might become optional.
Currently the following types are supported: Data::URIID::Base, Data::Identifier, URI. Other types might be supported as well.
type
-
The type of the barcode. One of
TYPE_*
. Future versions of this module might improve this definition.
data
my $data = $barcode->data;
Returns the data of the barcode.
The returned value might differ from the value passed to "new" as it might have been normalised, decoded (character set), or otherwise altered.
No options are supported. However the options default
, and no_defaults
are ignored.
type
my $type = $barcode->type;
Returns the type of the barcode.
The returned value might differ from the value passed to "new" as it might have been normalised, replaced with a cached reference, or otherwise altered.
No options are supported. However the options default
, and no_defaults
are ignored.
See "has_type" for a more convenient method.
has_type
my $bool = $barcode->has_type(Data::URIID::Barcode->TYPE_*);
Returns whether or not this barcode is of the given type.
No options are supported. However the options default
, and no_defaults
are ignored.
render
$barcode->render(filename => ...);
Render the barcode as a image file.
Experimental: This method is experimental. It may change completly or may be removed on future versions.
Note: Currently this method exports as PNG. Later versions might support other formats.
TYPES
This module supports a number of types of barcodes.
Note: This module does not define the type or value the TYPE_*
constants have. Future versions of this module might change this at any release. Always use the type constants.
TYPE_UNKNOWN
The type of the barcode is unknown. This might be used if e.g. the scanner software does not tell. However this limits the set of features this module can provide.
TYPE_OTHER
The type of barcode is known, but not supported by this module. Future versions of this module might implement the given type.
TYPE_QRCODE
A QR-Code.
TYPE_EAN13
A EAN-13 code commonly found on products.
TYPE_EAN8
A EAN-8 code commonly found on products in small packages.
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2023-2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)