in reply to Why is my CGI.pm script trying to assign data before pressing submit.
I'll try to answer your question, but first a few curmudgeonly comments:
Are you familiar with the state machine model of CGI programming? (Try a Super Search for "state machine" more info.) The idea is that your CGI script needs a way to remember what part of the interactive process it is presenting.
Your script would probably have three states, let's call them "edit", "preview", and "commit".
# Set state to edit if not defined. param(state)||param(name=>'state', value=>'edit'); if (param('state') eq 'edit') { # display the form print start_form('POST',self_url()); # blah blah blah print submit('state','preview'), end_form(); } elsif (param('state' eq 'preview') { # display the results, prettily. print start_form('POST',self_url()), # A bunch of hidden fields to pass our data along hidden(parameter-n, value), # This button commits the data to a file. submit('state','commit'), # This button returns to the edit form, to make changes. submit('state','edit'), end_form(); } elsif ( param('state') eq 'commit') { # Save the file # Print some nice messages. } else { # General purpose error. You should never wind up here # Trap it just in case. }
I personally, prefer to use here docs for embedding HTML in my perl. I find CGI.pm's HTML generation cumbersome. But some people really like it, TIMTOWTDI. I always use CGI.pm for parameter management though.
# A sample here doc print <<"END_OF_HTML"; Blah laalbalalsdfasdf asdf blaha END_OF_HTML
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Why is my CGI.pm script trying to assign data before pressing submit.
by andye (Curate) on Dec 07, 2001 at 14:37 UTC | |
|
Re: Re: Why is my CGI.pm script trying to assign data before pressing submit.
by Amoe (Friar) on Dec 07, 2001 at 22:08 UTC | |
by TGI (Parson) on Dec 10, 2001 at 07:27 UTC |