use strict; use warnings; my @id=(1,2,3,4,5); my $sql = "SELECT name FROM table where id in (".join( ",", @id).")"; print "$sql\n";