I fail to pinpoint a particular problem in your question. Is it the "how do I connect to the database" issue you have a problem with? Is it "how do I process records"? Is it "how do I write a Perl program"? Is it "please write a program for me?". Please elaborate. And tell us what you've done so far.