CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
CGI - The other way round...


New User

May 21, 2002, 2:01 PM

Post #1 of 2 (1914 views)
CGI - The other way round... Can't Post


I would like to program a Perl module which offers another way to program CGI-Applications.
(As a Semester Project)

The programmer should be able to abstract the hole task of :
- presenting a form to the user (HTML-Generation)
- doing sanity checks on the input (Form-Processing)
- presenting the form again, if errors are found, etc...
in a sub-routine call. (The formdata could be seen as the return value of the subroutine.)

Of course if the user posts the data, it will restart the entire script. So my Module would
basically provide a way to the programmer to "resume" the script where is left of.
(INSIDE the subroutine that generated the form.)
Lets assume I use sessions to save all the needed data between requests.

There are two major problems,and i have no idea how to solve them.
Perhaps one of the Perl-Gurus out there have a hint or two ;-)

Each time a HTML-Page is send to the user, the programmer would call the function State::Save.
Somehow the State Module must then be able to gather all information about the interpreters state
(stack, lexical and global variables), and save it in a persistent session. Then, State::Save() simply exits.

Problem 1: How does one access the stack and all the variables (Inside Perl / XS) ?

The user sends then the filled in form back (Post/Get), and the script gets started again.
The State Module should intercept execution immediately with a BEGIN block and check
if the requests session has state-data. If so, the module has to restore the stack and variables,
then it has to resume execution where it left of.

Problem 2: How does one manipulate the stack (Inside Perl / XS ) ?

Once the Stack is restored, I assume, I could use the special Syntax used by AUTOLOAD to jump
directly inside the State::Save routine, which would this time return directly to the calling user routine.
There, the user routine could begin with some form checking, value parsing, an would end up returning the
formdata to the application.

Is this possible at all ? performance problems ?

Thank you for thoughts, implementation ideas and comments.

Best Regards

Thomas Seiler
Communication Systems Student


May 22, 2002, 12:27 PM

Post #2 of 2 (1907 views)
Re: [thseiler] CGI - The other way round... [In reply to] Can't Post

Here are some not quite random thoughts that may (or may not) help with your quest...

There was a [url=""]thread on almost two years ago about determining variable names from a reference.

Will you use CGI; in your module and build a wrapper or are you going to be so bold as to do your own parsing of the form data?

You might find something useful in Data::Dumper, B::Deparse, and the other B::* modules.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives