Barcode Reading

| | Comments (0)
A couple of years ago I got a free CueCat USB barcode reader. I did some stuff so I could use it on my Mac. Well, I wanted to use it on Mac OS X, so I grabbed the old script, installed Barcode::Cuecat, modified my little script to save to the Mac OS X clipboard, and away I go.

#!/usr/local/bin/perl -s
use warnings;
use strict;
our($c, $p);
 
use Barcode::Cuecat;
 
my $bc = new Barcode::Cuecat;
print "Type 'q' to quit.\n" if $c;
 
while (chomp(my $data = <STDIN>)) {
        last if $data eq 'q';
 
        $bc->scan($data);
        printf "%s: %s\n", $bc->type, $bc->code;
        if ($p) {
                open my $clip, '|pbcopy' or die $!;
                print $clip $bc->code;
                close $clip;
        }
 
        last unless $c;
}

Usage:

[pudge@bourque bin]$ cuecat -p
^[[28~.C3nZC3nZC3n2D3bWDhvZDxnY.fGzX.C3T1D3DYE NzZ.
UE2: 086441950

And then "086441950" is put onto the clipboard (BTW, that is a scan of the new TV Guide with Aragorn on the cover ... no, YOU'RE a geek!). Also, since I am using ClipboardSharing, I keep the reader connected to my server at my desk, and after running this program, it automatically sends the clipboard to my main workstation. ClipboardSharing is way neat. use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on December 12, 2003 3:49 PM.

SSHKeychain was the previous entry in this site.

Contracts is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.