Alright, here's a code snippet:
<CODE>
@DB_FIELDS=(name phone etc);
my $fields = join (', ', @DB_FIELDS);
$i=0;
while ($i < $loops){
my $j=0;
foreach $field (@DB_FIELDS) {
@values[$j] = "\$" . $field . $i;
$j++;
}
....
$values .= join (', ', @values);
someFunction($db, $fields, $values);
$i++
}
</CODE>
So, $values should look like '$name0, $phone0, $etc0, $name1, $phone1,
$etc1, $name2...'.
This is used to build an SQL command. The command is:
<CODE>
my $insert_string = qq~INSERT INTO $db ($fields) VALUES ($values)~;
my $sth = $dbh->do("$insert_string") or croak $dbh->errstr;
</CODE>
This loops several times depending on the number of inputs from the user.
I'm doing this because I have no idea how many "$values" will be
inserting into the database because it's coming from a dynamic HTML form
that grows depending on the user's input.
Gunnar said:
Geoff said:
I have an array:
@array = [\$a, \$b, \$c];
It's an array with one element that consists of a reference to an
anonymous array with three scalar references.
How do I evaluate what $a is?
print ${$array[0][0]};
I've tried:
print $array[0];
But this gives me "$a".
Sounds very strange. It should give you something like
'ARRAY(0x15551bc)'. You'd better post some complete code that
illustrates the behaviour you describe.