But whenever I click on any button it is taking me the perl CGI script. Not operating accordingly.
That is what you are telling it to do. What did you expect it to do? You should post a minimal bit of code, showing the html form, and the cgi script code. Include the part that connects to the db.