Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

17 views
Skip to first unread message

day...@gecko.org

unread,
Mar 26, 2005, 3:05:43 PM3/26/05
to
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ürgen Exner

unread,
Mar 26, 2005, 3:11:36 PM3/26/05
to
day...@gecko.org wrote:
> 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


0 new messages