magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 1998 > 10 > Programming with Perl  

Formatting HTML for CGI.pm

The CGI.pm module, created by fellow columnist Lincoln Stein, is the most commonly used method for dealing with all the ins, outs, and roundabouts regarding the common gateway interface. One of the nice features of this CGI module is that there are numerous HTML-creation subroutines. I personally find it easier to type

h1("Welcome to my Fred & Barney page!")
than it is to type
<h1>Welcome to my Fred &amp; Barney page!</h1>

especially when the content or the parameters come from various variables. Now, if I'm constructing a new form generator and form response program from scratch, I just start typing the correct HTML-creation routines, and I'm done.

But let's say I had started with a static HTML form page, which had originally referenced a CGI program (perhaps something that uses the CGI module, but not necessarily), and now I want to roll it up into the "same program generates the form and handles the response" method. I've got all this nice HTML that should be the output of the HTML-creation routines. What I want are the routines that could have created that output.

Perl to the rescue! All we have to do is parse the HTML (easy enough with some of the existing LWP library components), and dump the parsed structure in a way that's compatible with the CGI module's routines.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2