From the Content-type header, I'm assuming you are trying to return the html to a browser. In that case, don't print the html to a file, rather print it directly to standard out as you did for the header. However, I will also note that direct html generation is not very popular as it becomes difficult to maintain as the size of your problem grows. Therefore, most people turn to either a templating system (like
Template,
HTML::Mason, etc.) or CGI.pm to do the generation.
Phil