select name,value from A where name in ('a','b','c','d','e')
####
# Make a quoted list of strings
my @quoted_vals = map { "'$_'" } @var1;
my $sth3 = $dbh->prepare("select name,value from A.database1 where name in ("
. join(",",@quoted_vals) . ")"
) or die "Can't prepare statement: $DBI::errstr";
####
select name,value from A where name in (?, ?, ?, ?, ?)
####
# Build SQL statement with question marks instead of values
my $sth3 = $dbh->prepare("select name,value from A.database1 where name in ("
. join(",", "?" x @var1) . ")"
) or die "Can't prepare statement: $DBI::errstr";
# Tell DBI to replace the question marks with the list of values
$sth3->execute(@var1);