CGI Application Modules for CPAN
if else block performs the required action using more CGI.pm calls, and ends by 
printing out the HTML for the page. Since I'm not trying to teach CGI program 
ming, I've left out the implementation of these functions.
This code employs a set of heuristics to determine which action to perform for 
the user. For example, it knows the user is saving a message by the presence of a 
CGI parameter called subject. If a user wants to read a message, then the msg_id
parameter will be included in the request and the script will know to act accord 
ingly. This approach has a major flaw it makes adding new features much harder 
than it should be.
For example, imagine adding support for replying to a message. This action 
will need only one parameter the message ID for the message being replied to. 
Thus, the elsif block might look like the following:
} elsif ($query >param("msg_id")) { # is the user replying to a message?
  do_reply();
}
But this won't work; the do_read() functionality is already using msg_id, and 
do_reply() will never be called! Instead you'd have to distort your parameter 
names to avoid clashing by adding a new parameter:
} elsif ($query >param("reply_msg_id")) { # is the user replying to a message?
  do_reply();
}
The problem here is that the CGI script has no way to know what the user is 
really doing it just looks at the incoming request and makes an educated guess. A 
small error on one form can lead your program down the wrong path with disastrous 
results. Also, understanding how the program works is unnecessarily difficult.
CGIs as State Machines
Many CGI programs, including the example shown earlier, can be viewed as finite 
state machines (or just state machines). A state machine is a system characterized 
by a series of discreet states and events that provide transitions between states. In a 
CGI like the BBS, the events are actions performed by the user, usually by clicking 
a button or following a link. In response, the application enters a particular state. 
In the preceding example, the do_save() subroutine is a state entered in response 
to the user saving a message. The output of this subroutine is displayed to the user. 
Thus, from a user's perspective, events are mouse clicks and states are screens of 
the application.
25
257
7






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved