This is something that I whipped up to show that a CueCat can be useful. It works pretty much like the UPC Database.
#!/usr/bin/perl use strict; use warnings; use Barcode::Cuecat; use DBI; my $db = "database"; my $db_engine = "mysql"; my $host = "localhost"; my $user = "username"; my $password = "password"; my $dbh = DBI->connect("DBI:$db_engine:$db:$host",$user, $password,{ P +rintError => 0}) || die $DBI::errstr; my $bc = new Barcode::Cuecat(); print "Mr. Muskrat's Item Database Lookup\n"; print "Version 1.0\n\n"; ShowWhatToDo(); while (<>) { last if /^\n$/; my $test = $bc->scan($_); my $type = $bc->type(); my $upc = $bc->code(); ShowItemInfo($dbh, $upc); } continue { ShowWhatToDo(); } my $rc = $dbh->disconnect; exit; sub ShowItemInfo { my ($dbh, $upc) = @_; my $table = "upca"; my $select = "upc, units, description"; my $sth; my $where = "upc = $upc"; print "\n"; $sth = $dbh->prepare("SELECT $select FROM $table WHERE $where;"); if (!$sth) { die "Error:" . $dbh->errstr . "\n"; } if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; } my $row_ref; while($row_ref = $sth->fetchrow_arrayref) { print "UPC: $row_ref->[0]\n"; print "Units: $row_ref->[1]\n"; print "Description: $row_ref->[2]\n"; print "\n"; } my $rv = $sth->finish; } sub ShowWhatToDo { print "----------------------------------------------\n"; print "\n"; print "To get info on an item, scan it's UPC barcode.\n"; print "To exit, press the Enter key.\n\n"; }

In reply to UPC Lookup by Mr. Muskrat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.