NB: These pages were mostly written in 2001 or so. The résumé dates are accurate but the code is aged and unlike whiskey, 8 year-old code doesn't usually taste better. For a look at my current skills and to see my CPAN modules, sample code, and code discussions, please see these pages instead: Perl resources and sample code and PangyreSoft.
CGI with stylesheet
Social links
View Ashley Pond V's profile on LinkedIn
Miscellaneous

Other pages

Description

CGIs get muddy quickly. The mix of code and HTML in a long form that is designed to be eye pleasing can make an eyesore for the coder. You can do lots of HERE statements to print your HTML to help or move to a templating system when the HTML going gets tough.

Here’s a little trick that helps keep it in the realm of a single CGI when that’s what you need. Notice too that we’re calling CGI::Pretty instead of CGI. It works exactly the same but the HTML output is much easier on the eyes.

Update: see use CGI Perl with CSS for many more options for Perl + CSS.

Discussion

Stylesheets go a long way to trimming HTML. Usually you’d want to have the stylesheet be outside the CGI or HTML files. But if you are doing a stand alone CGI for someone or for generic distribution it might be best to have the style guides in the CGI. Makes for easier installs. It also ensures some webtwerp won’t edit or delete the stylesheet without letting everyone know.

It’s also quite easy to use CGI or CGI::Pretty to include external stylesheets too. Just add it in your start_html(). One example below and many more explored here: use CGI Perl with CSS.

Search these pages via Google
Text, original code, fonts, and graphics ©1990-2009 Ashley Pond V.