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"; }
In reply to Re: help with Barcode::Code128
by gmargo
in thread help with Barcode::Code128
by djbryson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |