spacer

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

home / experts / perl / tutorial / 3

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

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.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags


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

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