spacer

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

home / experts / perl / tutorial / 3

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


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

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