in reply to help with Barcode::Code128
I am confused about what you are looking for. You are setting the text to encode three different times, and generating two separate images, although you only save the last one to a file. That last one has a fixed string ("CODE 128") so you should be getting the same .png file each time.
Here's some quick-n-dirty code that produces three barcodes with different integer texts, hope it can help you.
#/usr/bin/perl use strict; use warnings; use diagnostics; use Barcode::Code128; my $times = 3; print "Running Barcode... encoding $times random integers\n"; my $object = Barcode::Code128->new(); $object->code('A'); # Enforce 128A? srand(0); # More interested in repeatability than randomness foreach (1 .. $times) { my $text = ""; # Make up a 10-digit decimal number $text .= "".int(rand(10)) foreach (1 .. 10); my $filename = "code128_".$_.".png"; open(my $png, ">", $filename) || die("Cannnot open $filename: $!") +; binmode($png); print $png $object->png($text); close($png); print "Text \"$text\" encoded in file $filename\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: help with Barcode::Code128
by Anonymous Monk on Oct 24, 2011 at 08:50 UTC | |
by Corion (Patriarch) on Oct 24, 2011 at 08:54 UTC | |
by AATG_PERL_1010 (Initiate) on Oct 24, 2011 at 09:11 UTC | |
by Corion (Patriarch) on Oct 24, 2011 at 09:13 UTC | |
by AATG_PERL_1010 (Initiate) on Oct 24, 2011 at 09:17 UTC |