#!/usr/bin/perl -T # You do have taint mode turned on, don't you? and the next two lines, too? use strict; use warnings; my $cgi_obj = new CGI; my $page = $cgi_obj->header( 'text/html' ); $page .= display( $cgi_obj ); print $page; sub display { my ( $query ) = @_; my $html = qq~ ... (initial boilerplate stuff for the page) ... ~ # run your dbi queries... # append more html stuff to $html as you go, and finally: $html .= qq~ ~; return $html; }