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

Discussion in 'Perl' started by dayton@gecko.org, Mar 26, 2005.

  1. Guest

    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?
    , Mar 26, 2005
    #1
    1. Advertising

  2. 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
    Jürgen Exner, Mar 26, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mfglinux
    Replies:
    11
    Views:
    695
    Roberto Bonvallet
    Sep 12, 2007
  2. Replies:
    6
    Views:
    155
    Bob Barrows [MVP]
    Oct 13, 2007
  3. David Filmer
    Replies:
    19
    Views:
    237
    Kevin Collins
    May 21, 2004
  4. Replies:
    12
    Views:
    150
    Tad McClellan
    May 18, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    364
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page