my @fields = qw(fornavn efternavn cpr adresse zip city tjenestested); my $cgi = new CGI; # apply validation/error checking as needed # in this case, if no param is found, undef is default my @params = map { $cgi->param($_) || undef } @fields; # connect to database . . . my $sth = $dbh->prepare( 'INSERT into people(' . join(',', @fields), ') values(' . join(',', map { '?' } @fields), ')' ) or die $dbh->errstr; $sth->execute(@params) or die $dbh->errstr;