A Perl script catalogs books and CDs with the help of barcodes
To allow the Tk toolkit's photo widget to read and display JPEG images, line 8 loads the Tk::JPEG module, which is also part of the Tk distribution. The img_display() function defined in line 158ff. expects the URL for an image hosted by Amazon.com and then asks the POE-friendly user agent to retrieve it.
Because the Tk photo widget insists on Base64-encoded data (at least for JPEGs), the encode_base64() function from the MIME::Base64 module converts the JPEG data extracted via content() into a format that the widget will handle. After this, the photo widget's configure() method sets the -data option, which in turn tells the widget to parse the data, convert it to the internal Tk format, and display the decoded image in the GUI.
Database with Wrappers
Now back to the resp_process() function: It not only displays the product data, but also stores it in the database. To allow this to happen, in line 128 the Rose::DB wrapper creates a new Article type object and sets the object's upc, type, title, and bywho fields, which all correspond to the database table columns with the same names.
The load() method with the speculative attribute then attempts to find a matching entry in the database. If the search succeeds, the script sends an "ALREADY EXISTS" message to the GUI display to tell the operator that this product has already been scanned. If load() fails, save() in line 149 saves the newly entered article in the database.
Before the script can use AWS, you must apply for an Amazon developer token and enter it in line 89. This process is fast, and you can trigger it  by entering a valid email address to which the token will be sent. Without a valid token, the script will say NOT FOUND every time. The database is created by the SQLite client sqlite3 when the schema file (Figure 6) is passed in to it:
sqlite3 articles.dat <schema.sql
The client then creates the articles.dat database and an empty database table, articles, containing the columns id, upc (the UPC/EAN code), type (Books, Music, or DVD), title (the title of the book or CD/DVD), and bywho (the author or artist).
The UNIQUE command in the database table's SQL uses the article type and UPC number as unique keys to allow the Rose database wrapper to run load() quickly and check to see whether the product with a given UPC and type has already been scanned.
Buy this article as PDF
New partnership will bring more and better CS training to US schools
Criminals offer online help over Tor network
Sophisticated malware is still present on Joomla and WordPress sites around the world.
New release marks the arrival of AMD’s unified driver strategy.
A new study by IDC charts big changes in the big hardware market.
Azure CTO says Redmond has already considered the unthinkable.
Lead developer quells rumors that the Debian version is slated for center stage.
MSBuild is now just another GitHub project as Redmond continues its path to the light.