#!/usr/bin/perl -w use strict; use CGI; my $q = new CGI; my $subbut = $q->param("submitbut"); my @inventory = qw(books paper pencils erasers); print $q->header; print $q->start_html(); my %qty=(); my %inv_prices=(); my %inv_weights=(); if ($subbut eq 'Submit') { foreach (@inventory) { my $qty = $q->param("quantity$_"); $qty{$_} = $qty; } print "

"; foreach (@inventory) { print ""; print ""; print ""; } print "
$_$qty{$_}
"; } else { print "
\n"; foreach (@inventory) { print ""; print ""; print ""; print ""; print "\n"; } print ""; print "\n"; print "
$_$inv_prices{$_}$inv_weights{$_}
\n"; } print $q->end_html;