CGI Development - Multiple Entry or Dispatch

Scott Penrose scottp at
Sun Nov 3 17:01:07 CST 2002

On Monday, Nov 4, 2002, at 18:03 Australia/Melbourne, David Dick wrote:

> can you give a short code example of what you mean by multiple entry 
> and dispatch methods?


	use MyImplementation;
	my $m = MyImplementation-new();

	if ($ENV{PATH_INFO} eq "") {
	} elsif ($ENV{PATH_INFO} eq "edit") {
	} elsif ($ENV{PATH_INFO} eq "save") {
	} else {

OR, multiple methods

	use MyImplementation;

	use MyImplementation;
	use MyImplementation;

Of course in the multiple version, you generally actually implement the 
code there, rather than just calling another method.

The advantages of single point of entry are:
	- Single location of code
	- Single point for setting up, database handles, config etc
	- Easier to make mod perl

The advantages of multiple entry points are:
	- Easier to implement
	- Faster to load (less code to compile)
	- Getting the web server to do what you would have to do manually.
	- More flexibility on installation (just web server config changes)


> Scott Penrose wrote:
>> Hey Dudes,
>> When developing CGI, wether via web application style (ala Mod Perl) 
>> or individual (ala CGI) you get the choice of having multiple entry 
>> points or a dispatch.
>> Most programs never go for complete multiple entry. Usually you will 
>> get a CGI script to view, edit and save an entry of some type (eg: in 
>> a database). So even multiple entry points have at least some 
>> dispatch.
>> An alternative is to have a single entry point for an application, 
>> where you have a dispatch (usually around the rest of the PATH) to 
>> decide if you want to list vs edit vs save etc.
>> Do people have an opinion on what is the better way and why? What 
>> would you recommend if you were developing all over again ?
>> Scott
Scott Penrose
Welcome to the Digital Dimension
scottp at

Dismaimer: Contents of this mail and signature are bound to change 
randomly. Whilst every attempt has been made to control said 
randomness, the author wishes to remain blameless for the number of 
eggs that damn chicken laid. Oh and I don't want to hear about 
butterflies either.

More information about the Melbourne-pm mailing list