my %mappings_form2db = ( # form => db counter => 'count' , name => 'name' , tel => 'telephoneNumber', ); my $cgi = CGI->new(); my %params = $cgi->Vars(); # hier dann die gueltigkeit ueberpruefen # ... # und dann das sql bauen: my $sql = qq~INSERT INTO table (~ . join (', ', values %mappings_form2db) . qq~) VALUES (~ . join(', ', map { $dbh->quote($params{$_} ) } keys %mappings_form2db . ")";