CGI Application Modules for CPAN
CGI::Application is an abstract base class in object oriented terminology. This 
means it provides all its functionality by serving as a parent class. You can't use 
CGI::Application directly, you have to create a subclass. The start of Listing 11 1, 
placed in a file called BBS.pm, does just that:
package BBS;
use CGI::Application;
@ISA = qw(CGI::Application);
This creates a new module called BBS that inherits from CGI::Application.
Next, the class implements the one required method, setup(). The setup()
method is called from CGI::Application >new(). It is responsible for setting up the 
run modes for the class. Run modes provide a direct implementation of the events 
shown in the state machine for this application. They replace the if elsif structure 
of the earlier example.
The setup() method works by calling methods inherited from CGI::Application, 
specifically mode_param(), start_mode(), and run_modes():
sub setup {
  my $self = shift;
  $self >mode_param("rm");
  $self >start_mode("list");
  $self >run_modes(list  => "list",
                   save   => "save",
                   new    => "new_message",
                   read   => "read",
                   reply  => "reply",
                   search => "search");
}
The mode_param() method tells CGI::Application that the CGI parameter with the 
name rm will control the run mode of the program. This means that each HTML 
form sent to this CGI will have a parameter called rm set to a run mode. For example, 
this might take the form of a hidden input field:
When the form containing this tag is submitted, the application will enter the 
 save  run mode. By tracking the run mode in a single parameter, CGI::Application 
always knows which event is being called. In contrast to the heuristic if elsif struc 
ture seen earlier, this system is durable and simple to understand. CGI::Application 
simply looks up the value of the rm parameter in the table passed to run_modes()
and finds a method to call in the application class.
26
261
1






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