#!/usr/bin/perl -wT use CGI qw(:standard); $ItemForm = param('item'); $AmountForm = param('amount'); $OldLine = `grep $ItemForm stock.dat`; ($item, $OldHeld, $order)=split(/” “/, $OldLine); $NewHeld = $OldHeld-$AmountForm; $NewLine= join (" ",$item, $NewHeld, $order); open(STOCK,"items.dat"); @items=; close STOCK; for ($i=0; $i < $#items; $i++) { $items[ $i ] = $NewLine if ($items[ $i ] eq $OldLine); } open (STOCK,">items.dat"); foreach (@items) { print STOCK; } close(STOCK);