my $sth = $dbh->prepare( <<__END_SQL__ ); SELECT Table1.Name ,Table1.Address ,Table1.City ,Table1.State ,Table1.ZIP ,Table1.Phone FROM Table1 WHERE Table1.BusType = ? __END_SQL__ foreach my $line ( @lines ) { $sth->execute( $line ); # Do whatever you wanted with the executed statement, like fetch() $sth->finish; }