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 > 1999 > 11 > Programming with Perl

Automatically Testing a Form

I've written quite a few CGI programs to handle form data. I'm always interested in finding ways to test these form handlers, especially ways to invoke them with canned or computed data, or even to stress test them.

Of course, it's easy to write a Perl program that invokes a CGI script to handle computed form data. You just whip out LWP, add a dabble of HTTP::Request::Common, figure out what you want the form to be filled with, write the code, and you're done.

But what if there are many fields, or you didn't write the form yourself and you're having trouble scanning through the HTML source code to get all the form input fieldnames and default values? Well, Perl can help with that, too. After all, we can parse HTML and generate Perl programs with Perl programs. What if we wrote a Perl program to invoke the URL of the form page, study the resulting HTML, and come up with another Perl program that invokes the resulting form action script? Well, that doesn't have to be a "what if," because such a program is presented in Listing One.

Lines 1 through 3 enable warnings, common compiler restrictions, and disable buffering on STDOUT, letting us see output as it occurs.

Lines 5 through 9 bring in five modules from the LWP library, found in the CPAN (at



  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