spacer

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

home / experts / perl / tutorial / 3

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

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


The Network for Technology Professionals

Search:

About Internet.com

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

webref The latest from WebReference.com Browse >
Installing and Using Meeplace, the Business Review CMS · Sending an HTML and Plain Text E-newsletter with ASP.NET, Part 2 · Create Multilingual Web Sites with Windows Unicode Fonts
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Top 10 Threats to Wireless Security · Poll: UC Uptake on the Rise · Review: Fluke AirCheck Wi-Fi Tester 1.0


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

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