in reply to Inserting 2 arrays into 2 field in MySQL

my $sth = $dbh->prepare(" INSERT INTO `trial` ( User, Time ) VALUES ( ?, ? ) "); foreach my $i (0..$#array1) { $sth->execute($array1[$i], $array2[$i]); }

Replies are listed 'Best First'.
Re^2: Inserting 2 arrays into 2 field in MySQL
by poolboi (Acolyte) on May 15, 2008 at 05:48 UTC
    thanks for your help it worked just a question what does
    foreach my $i (0..$#array1);
    means?

      $#array1 returns the last index of the array so that iterates over the indexes of the array. Hopefully, the following example will help you understand:

      my @array = qw( a b c ); for my $i (0..$#array) { print("$i: $array[$i]\n"); }