my @a=keys(%prophash); my $a=join(',',@a); my @b=values(%prophash); my $b=join(',',@b); my $temp="insert into maintable ($a) values($b)"; $sth = $dbh->prepare ($temp); $sth->execute();