How to handle error?

Hi,

I am having a page named exec.php.And in that page i am executing a perl script,and i am displaying the result in the same page.if it was not able to execute successfully, it returns some error.

if error returns,the actual page’s layout is changed.

i want that layout of the page to remain same. what i have to do for handling this?

please anyone help me…