@fields = qw(Name ID Age); #assuming $dbh and $q exist, and primary key in $key my $statement = 'update my_table '.join(",", map {"set $_ = ?"} @fields)." where Key=?"; my $sth = $dbh->prepare($statement); $sth->execute(map({$q->param($_)} @fields), $key);