Creating a variable using a for() loop???

D

dayton

I have a form that is dynamiclly generated from a database. Using the
CGI module, I'm trying to parse the parameters returned, but since the
number of paramaters changes I can't get the variables assigned...

What I'm trying:
--------------
$count='1';
while (my(@data)=$table_data4->fetchrow_array) {
print qq|
<tr><td><input name=rs$count type=text
maxlength=7 size=7 value=$data[0]><td>$data[1]
|;
$count++;
}
--------------------

which correctly populates the table but then when I try to parse the
parms..

(like : if (param()){ $buh = param('buh') || '';}

I run into my problem. I've tried:

----------------------
for ($i=1;$i<=$number;$i++)
$R$i="rs$i";
}
----------------------

and the error I get is:

Scalar found where operator expected at ./test line 5, near "$RS$i"
(Missing operator before $i?)
syntax error at ./test line 5, near "$RS$i"
Execution of ./test aborted due to compilation errors.


How can I auto-generate the variables based on the # of params created
by the form?
 
J

Jürgen Exner

I have a form that is dynamiclly generated from a database. Using the

What a coincidence. A namesake of yours just posted exactly the same
question to comp.lang.perl.mics.
You may want to check there for replies he got.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top