in reply to CGI problem: trying to assign parameters in a loop

Here's a wild (untested) idea for the second script:
my %quantities = map { (my $name = $_) =~ s/^quantity//; $name => param($_); } grep { /^quantity/ } param(); ;
I think there may be a better way to represent your data as HTML form widgets, but it's not coming to mind immediately.