# assume this is the hash containing translated XML nodes my %hash = ( phone => '456', street => 'Malcom St.' ); my @fields = keys %hash; my $ID = "34567"; my $update_query = qq{UPDATE address\n SET} . join(",\n", map { " $_ = ? "} @fields) . qq{\nWHERE id = ?}; print "$update_query\n"; my $sth = $dbh->prepare($update_query); my $rows = $sth->execute(@hash{@fields}, $ID); print "$rows rows affected\n"; __END__ The query produced by this code is UPDATE address SET phone = ? , street = ? WHERE id = ?