I pretty much copied and pasted as well and came to the same conclusion as bjelli in her comment.
Just added a few things on real quick to make an inclusive script as well and was able to run without issue.

#!/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 "<br><br><TABLE>"; foreach (@inventory) { print "<TR>"; print "<TD>$_</TD>"; print "<TD>$qty{$_}</TD></TR>"; } print "</TABLE>"; } else { print "<form><table>\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$_\"></T +D></TR>\n"; } print "<TR>"; print "<TD><input type=\"submit\" name=\"submitbut\" value=\"Submit\ +"></TD>\n"; print "<TD><input type=\"reset\" value=\"Clear\"></TD></TR></table>< +/form>\n"; } print $q->end_html;


nandeya

In reply to Re: CGI problem: trying to assign parameters in a loop by nandeya
in thread CGI problem: trying to assign parameters in a loop by bighara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.