push(@where_array, 'item1 = ?'); push(@params, $item1); push(@where_array, 'item2 = ?'); push(@params, $item2); push(@where_array, 'item3 = ?'); push(@params, $item3); my $select = join(', ',@select_array); my $where = join(' and ',@where_array); my $script = "SELECT $select FROM table WHERE $where"; . . . $sql->execute(@params);