[kclug] bar-q 0.10 Release.

Monty J. Harder dmonster at juno.com
Sat Sep 9 02:21:57 CDT 2000


  After thinking about the criteria we talked about, I think brevity of
source code far outweighs any performance considerations.  After all,
we're translating a single line of gibberish here.  So, without further
adieu, I release unto The Community... bar-q, in t-shirt-ready 29 lines
of perl, comments included:

#!/usr/bin/perl
print "n","-" x 64,"
bar-q Translator 0.10  (c)2000 Monty J. Harder.
Licensed under the GNU Public License, Version 2 or later.  
n";
# This program is provided "as is", without warranty
# of any kind, either expressed or implied.

foreach $E (a..z,A..Z,0..9,'+','-') { $T{$E}+=$i++; }
#build lookup table

$E = vec($E,0,1); #dummy to force bitwise xors.

sub D
 {
  $E = unpack('B*',pack('c*', at T{split(//,$_[0])} )) ;
  # repack only the least-significant 6 bits of each byte
  $E = pack('B*', join("",unpack('x2a6'x (length($E)/8) ,$E)) );
  return(  $E ^ ( "C" x length($E) )  );
 }

if (!$ARGV[0]) {$ARGV[0]=<STDIN>;print"b";}
($nul, $SerNo, $BarType, $BarVal, $nul)  = split('.',$ARGV[0],5);
#$SerNo   = &D($SerNo); # not used here, but useful for chained devices

$BarType = &D($BarType);
$BarVal  = &D($BarVal);

print "n$BarType-type barcode: $BarValn";
________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.




More information about the Kclug mailing list