package HTML::QRCode; use strict; use warnings; our $VERSION = '0.01'; use Text::QRCode; use Carp; sub new { my ( $class, %args ) = @_; bless { text_qrcode => Text::QRCode->new, white => 'white', black => 'black', %args }, $class; } sub plot { my ( $self, $text ) = @_; croak 'Not enough arguments for plot()' unless $text; my $arref = $self->{text_qrcode}->plot($text); my ($white, $black) = ($self->{white}, $self->{black}); my $w = ""; my $b = ""; my $html .= ''; $html .= '' . join( '', map { $_ eq '*' ? $b : $w } @$_ ) . '' for (@$arref); $html .= '
'; return $html; } 1; __END__ =encoding utf8 =head1 NAME HTML::QRCode - Generate HTML based QR Code =head1 SYNOPSIS #!/usr/bin/env perl use HTML::QRCode; use CGI my $q = CGI->new; my $text = $q->param('text') || 'http://example.com/'; my $qrcode = HTML::QRCode->new->plot($text); print $q->header; print <<"HTML"; $qrcode HTML =head1 DESCRIPTION HTML::QRCode is HTML based QRCode generator, using Text::QRCode =head1 METHODS =over 4 =item new $qrcode = HTML::QRCode->new(%params); The C constructor method instantiates a new Term::QRCode object. =item plot($text) $arrayref = $qrcode->plot("blah blah"); Return HTML based QR Code. =back =head1 AUTHOR Hideo Kimura Ehide hide-k.netE Yoshiki Kurihara Yappo nipotan =head1 SEE ALSO C, C, C, C, C, C =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut