Haimov, Eugene wrote:

> Note:
> I know about CGI::Session and about Storable class. But I want to
> dig deeper. Please read on.
> 
> Hi everyone,
> I don't know how to explain the question in the commonly used terms,
> so let me start with an example.
> 
> Imagine a CGI script that needs to serve several different pages
> in succession. Here is roughly how I would inplement it:

<snip>

> Note that the communication with the user happens everywhere,
> including inside the function invocations. The problem is that I want
> to convert such a program ( as in example 2 ) into a CGI script.
> Too bad -- because I have to "cut" it at every spot where the
> "$xxxx = <>" happens, and provide a huge if/elsif structure to
> manage the continuation of the execution ( as in example 1 ). 
> Sometimes it is even impossible to "restore" the context -- as it is 
> for instance inside the functions.
> 
> The problem is not just the difficulty of doing it once.
> The problem is that if I actually cut the program into "pages",
> then it will lose its original structure completely, and it will be
> next to impossible to debug and further develop for those people
> who "understand" it in the original form.
> 
> Any idea or trick that wold allow to preserve the structure and
> still make it a CGI script ? Something magical like 
> "SaveStateCompleteIncludingCallStack()" ???

There are several different approaches you could take.

1) There could be different scripts for different sets of functions
   and you could use cookies to pass some args/state if needed.

2) You could load a module or 'do' some code in for that specific
   set of args (similar to 3 below codewise - except using 'do').

3) You could use a hash instead of if'ing all the possible args cases
   if (exists $code{$arg}) {  # where %code contains references to subs to 
process each arg type
      &$code{arg};
   } else {
      bad arg
   }

4) There are some templating systems that may be useful for this sort
   of thing.

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to