in reply to Using perl to Create a Table in a Database

Two hints:

1) You need to access those constructed variables from perl. You would either have to use the eval function or this:

for ($f... ... no strict 'refs'; my $x= ${$fieldname.$f}; use strict 'refs';

Those are called Symbolic References

2) You need to construct your query string. Remember that '.' is the operator for string concatenation.

UPDATE: kcott is right, hint 1 is wrong, false, not consistent with the facts and utterly misleading and I should have known better

Replies are listed 'Best First'.
Re^2: Using perl to Create a Table in a Database
by kcott (Archbishop) on Nov 04, 2010 at 14:44 UTC

    jethro, I may be missing something but that doesn't look correct.

    Just looking at the field names and the first loop iteration, he starts off with a normal assignment: my $fieldname="fieldname" .$f; so $fieldname is now "fieldname1".

    His 1st HTML INPUT becomes: <input type="text" name="fieldname1" /> (after interpolating $fieldname in <input type="text" name="$fieldname" />).

    In the second script, he'd do much the same so my $fieldname=param('fieldname'); would become my $fieldname=param('fieldname' . $f); (in a loop).

    -- Ken