[Previous] [Contents] [Next]


Generating HTML On-the-Fly with Perl5

There are two ways to define your form. The first is to create a static HTML file that contains all your form field definitions and reference the form to a particular CGI script. Another, perhaps easier, method is to dynamically display your form within your CGI script. The script can be called with a method get or a method post. When it is called with method get, you can respond with the form itself, and when it is called with method post, you can process the form request. Everything you print to stdout from your CGI script is returned back to the client (browser). This makes it very easy to generate HTML on-the-fly with Perl--especially when you use the CGI modules for form generation and processing. There is one drawback to this approach in that the Web server must execute a program to respond to the request rather than simply read a potentially cached file. If you don't mind the overhead of the extra process invocation, it will definitely make the job of maintaining your form and CGI program a lot easier.

[Previous] [Contents] [Next]