my $dbh = DBI->connect(...connection parameters...); my $get_foo = $dbh->prepare("select foo from table where bar=?"); $get_foo->execute(3); #select foo where bar=3 $get_foo->execute($baz); #select foo where bar=$baz