spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / perl / tutorial / 3

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

PerlHoo, Part II

Handling the Query String

Now that we know how to build a URL that sends an add request to the script, we will modify the perlhoo.pl script to handle it.

Let's begin by looking at Line 28:
use CGI::Carp qw(fatalsToBrowser);

The CGI::Carp module prints detailed error messages to your Web server's error log. By passing in the fatalsToBrowser token, it will also print errors to the Web browser which helps greatly in the debugging process.

Next, please note that I've added $new_datafile at Line 34 which defines the filename that recommended sites will be added to until they're removed or added to the PerlHoo directory.

Moving on to Lines 44-52, notice that the main body of our code now consists of an if->else control structure. Line 44 checks the value of $query->param('keywords'). If the value is add, it then executes &print_add_screen($reldir) or &add_link($reldir) depending on whether the CGI request method was GET or POST. For our purposes, we will use the GET method when we want to display the fill out form that users will use to recommend a new site. When we submit data using the POST request method, the script assumes that a user has just completed the form and is not sending the data to the script.

If $query->param('keywords') doesn't equal add, the script jumps down to Line 51 and executes &print_hoo($reldir) which prints the directory browse screens.


home / experts / perl / tutorial / 3

http://www.internet.com

Produced by Jonathan Eisenzopf and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: April 20, 1999
Revised: April 21, 1999

URL: http://www.webreference.com/perl/tutorial/3/