#!/usr/bin/perl # The LearningOnline Network with CAPA # Scott Harrison # YEAR=2001 # 8/15 # A CGI script that dynamically outputs a barcode. # I'm using format=Code39. # The valid formats are # EAN13, EAN8, UPCA, UPCE, NW7, Code39, # ITF, IATA2of5, Matrix2of5, and COOP2of5. use strict; use GD::Barcode::Code39; map { my ($name, $value) = split(/=/,$_); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; if ($name eq 'encode') { $ENV{'form.'.$name}=$value; } } (split(/&/,$ENV{'QUERY_STRING'})); # Tell the server we are sending a gif graphic print <new($ENV{'form.encode'}); warn($GD::Barcode::errStr); my $bindata=$oGdBar->plot->png; # create barcode image undef $oGdBar; binmode(STDOUT); open OUT,"|pngtopnm|ppmtogif"; # convert into a gif image print OUT $bindata; # output image $|=1; # be sure to flush before closing close OUT;