Removing print statements from cgi script



Does anyone know if its possible to remove data printed from a
web-page created from cgi.pm depnding on the effect of a sub-routine.

ie:

I print the header and a selection form which then runs a sub - is it
posible to replace the contents without loading a new web-page

Thanks
.