Perl scripts to do SQL and create HTML and Excel files

These are perl scripts that do SQL queries against our Sierra database and then process the output to create web pages and/or Excel files. We run these on a Windows server and start them using scheduled tasks. There are some for our web site, and some for staff:

For our web site:
On-order titles
Recently-added titles
Most popular titles
See ours at

For staff:
Purchase alerts: a different report for each group of locations; includes copies on order; does not include unavailable items (with icode2 = u); outputs a web page and Excel files

Unavailable items: missing, etc.; outputs a web page and Excel files

All titles: an Excel spreadsheet for each location or group of locations (included in the recently-added-most-popular script)

All items: an Excel spreadsheet for each location or group of locations

Each of these has two files, an “init” file to kick it off and loop through locations or groups of locations, and another file that’s run by the init file. You’ll need to change the files from .txt to .pl of course, and install Perl (I used ActivePerl) and the appropriate modules.

All of these seem to work and we’re using them in production, though your mileage may vary, and they’re probably not the most elegant code possible. I would welcome any feedback.


recently-ordered.txt (8.5 KB)
recently-added-most-popular-init.txt (2.6 KB)
recently-added-most-popular.txt (19.1 KB)
purchase-alerts-init.txt (873 Bytes)
purchase-alerts.txt (9.8 KB)
unavailable-items-init.txt (1.5 KB)
unavailable-items.txt (14.2 KB)
selectors-items-init.txt (2.6 KB)
selectors-items.txt (11.5 KB)
recently-ordered-init.txt (992 Bytes)