#!/usr/local/bin/perl # # chemstock2wais.pl -- convert Chem Stockroom data from raw format # to something suitable for WAIS # # Usage: perl chemstock2wais.pl < chemstock.raw > chemstock.wais # # Since we store this in the gopher data tree, it shouldn't be executable. # It's invoked from a Makefile. # # History: # 09/19/94 PASR Original version. # #------------------------------------------------------------------------- # INPUT DATA FORMAT # # One record per line, tab-separated fields (may contain blank lines # and/or end with \r\n): # # STOCK NUMBER # 5-6 characters # # DESCRIPTION OF ITEM # 80 chars max # # PRICE # floating point number (no "$" sign) # # QUANTITY ON HAND # (long) integer # # Example: # # 10010 ACETALDEHYDE, 250 GM 27.50 1 # 10020 ACETANILIDE, 1 KG 40.50 1 # #------------------------------------------------------------------------- # OUTPUT DATA FORMAT # # Blank-line-separated "paragraph" format with item description on first # line, e.g.: # # ACETALDEHYDE, 250 GM # Stock no. 10010 # Description ACETALDEHYDE, 250 GM # Price $27.50 # Qty on hand 1 # # ACETANILIDE, 1 KG # Stock no. 10020 # Description ACETANILIDE, 1 KG # Price $40.50 # Qty on hand 1 # #------------------------------------------------------------------------- while (<>) { if (($stockno, $desc, $price, $qty) = /^ *(\d+) *\t *([^\t]+) *\t *([\d.]+) *\t *([-\d]+)\s*$/) { print("$desc\n"); print("Stock no. $stockno\n"); print("Description $desc\n"); print("Price \$$price\n"); print("Qty on hand $qty\n\n"); } elsif (! /^\s*$/) { print(STDERR "Bad chemstock input: $_\n"); } }