http://www.perlmonks.org?node_id=140121


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

The problem must be somewhere else in your script. I just cut-n-pasted your code, and got it to run in 2 minutes. Here's my complete code:

#!/usr/bin/perl use CGI ('param'); print "Content-type: text/html\n\n"; print "<html><h1>Testing bigharas inventory problem</h1>\n"; @inventory = qw( camel llama ); if (param('action') eq 'submit') { print "Reading Data...<br>\n"; foreach (@inventory) { my $qty = param("quantity$_"); $qty{$_} = $qty } print "<table border=1>\n"; foreach (@inventory) { print "<TR>"; print "<TD>$_</TD>"; print "<TD>$inv_prices{$_}</TD>"; print "<TD>$qty{$_}</TD></TR>"; } print "</table>\n"; print "That's all\n"; } else { print "<form><table border=1>\n"; foreach (@inventory) { print "<TR>"; print "<TD>$_</TD>"; print "<TD>$inv_prices{$_}</TD>"; print "<TD>$inv_weights{$_}</TD>"; print "<TD><input type=\"text\" size=\"4\" name=\"quantity$_\" + ></TD></TR>" } print "</table><input type=submit name=action value=submit>\n"; }
--
Brigitte    'I never met a chocolate I didnt like'    Jellinek
http://www.horus.com/~bjelli/         http://perlwelt.horus.at