NAME
QRCode::Encoder - Create QR Codes in pure Perl
VERSION
This document describes QRCode::Encoder version 0.001.
SYNOPSIS
use QRCode::Encoder qr< qr_encode >;
my $message = '...';
my $encoded = qr_encode($message, level => 'H'); # hash reference
# The "plot" key is compatible with Text::QRCode
my $arrayref = $encoded->{plot};
print join "\n", map { join '', @$_ } @$arrayref;
DESCRIPTION
Generate QR Codes, compatibly with Text::QRCode.
The output of function qr_encode is NOT an image file, although it can be easily turned into one. As anticipated, much like Text::QRCode.
INTERFACE
qr_encode
my $encoded = qr_encode($octets, %opts); # OR
my $encoded = qr_encode(%opts);
Encode the message in $octets, with options in %opts.
Supported options are:
levelThe Error Correction level, expressed as a single-character string with allowed values
L,M,Q, andH, in increasing level of correction. If not provided, levelLis selected.modeThe mode of encoding, expressed as a string with allowed values
numeric,alphanumeric,byte, andkanji. If not provided, it is automatically guessed based on the contents of the provided$octets.octetsIn the first form, this is overwritten by the first argument. Otherwise, it represents the sequence of octets that will be encoded in the QR Code.
versionThe version of the QR Code, as an integer between
1and40. It is automatically calculated if not provided, based on the input$octetssize.
The output is a hash reference with the following keys:
levelThe Error Correction level, expressed as a single-character string with allowed values
L,M,Q, andH, in increasing level of correction.modeThe mode of encoding, expressed as a string with allowed values
numeric,alphanumeric,byte, andkanji.maskedAn array reference with the list of the different masked alternatives for the QR Code.
mask_idThe identifier of the mask that has been selected as best. It is an index for the
maskedarray reference, leading to a matrix equal tomatrix.matrixThe matrix selected as the result of the encoding, expressed as an array reference holding references to other arrays. Each position (module in QR standard terms) holds an integer value, whose least-significant bit is
0for a white module and1for a black module.plotAn equivalent of
matrix, with the same disposition but where each position holds a space character (0x20) for a white module and a star character (0x2a) for a black module. This is compatible with the output of theplotmethod in Text::QRCode.versionThe version of the QR Code, as an integer between
1and40.
BUGS AND LIMITATIONS
Minimul perl version 5.24.
Report bugs through GitHub (patches welcome) at https://github.com/polettix/QRCode-Encoder.
AUTHOR
Flavio Poletti <flavio@polettix.it>
COPYRIGHT AND LICENSE
Copyright 2025 by Flavio Poletti <flavio@polettix.it>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Just to be clear: apache-2.0