If you use CGI.pm, you can use the param() function to find out whether your script has been handed any input or not. Test for a return value from param(), process the form data if there is any, or output the blank form if there is none.
See
Lincoln Stein's CGI.pm page for more information.