On 6/13/07, Northstardomus <[EMAIL PROTECTED]> wrote:
snip
    $sth->execute($values[0], $values[1], $values[3]) or die $dbh-
snip

Two things:

1. If you always want to die on failure it is easier and safer to say

my $dbh = DBI->connect(
   $dsn,
   $user,
   $pass,
   {
       RaiserError => 1
   }
) or die DBI->errstr;

This will cause the DBI to die with DBI->errstr for any errors.

2.  If you are certain that @values has four values in it you can just say

$sth->execute(@values);

If you want to limit it to a specific subset of @values then use a slice*.

$sth->execute(@values[0 .. 3]);

* see perldoc perldata
      Entire arrays (and slices of arrays and hashes) are denoted by '@',
      which works much like the word "these" or "those" does in English, in
      that it indicates multiple values are expected.

          @days               # ($days[0], $days[1],... $days[n])
          @days[3,4,5]        # same as ($days[3],$days[4],$days[5])
          @days{'a','c'}      # same as ($days{'a'},$days{'c'})

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to