# assuming $cgi = new CGI; # prepare update query my $sth = $dbh->prepare(' update pic_table set pic_value=? where pic_id=? '); # loop over all param names, and # grep out all those that are numerical foreach my $p( grep /^\d+$/, $cgi->param) { # find the form value my $v = $cgi->param( $p ); # execute the query $sth->execute( $v, $p ); }