#!/usr/bin/perl use strict; use warnings; use GD::Barcode::Code39; MakeBar('0'); MakeBar('1'); sub MakeBar { my $txt = shift; my $oGdBar = GD::Barcode::Code39->new("*$txt*"); die $GD::Barcode::Code39::errStr unless($oGdBar); open(IMG, ">", "$txt.png") or die $!; binmode(IMG); print IMG $oGdBar->plot(NoText=>1, Height => 40)->png; close(IMG); } #### #!/usr/bin/perl use strict; use warnings; use Barcode::Cuecat; # seperate counters for open and closed my $open = 0; my $close = 0; my $door; my $bc = new Barcode::Cuecat(); while (<>) { $bc->scan($_); $door .= $bc->code(); if (length $door == 2) { $open++ if ($door eq "01"); $close++ if ($door eq "10"); $door = ""; # we will assume the door started out closed my $state = "closed"; $state = "open" if ($open > $closed); print "Opened: $open times\n"; print "Closed: $closed times\n"; print "Current state: $state\n"; # write to disk } }