Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Simple stateful web page using Perl
September 15, 2006, 2:09 pm
rate this thread
tell me it's a cgi programming question. I looked for a cgi
programming group but couldn't find one, so I hope this is a good place
to ask the question. ;-)
How would I write a simple web app in Perl+cgi that has state? Let's
say I just want to have a web page that has an input field, an Accept
button and a Clear button. Whenever I type some text into the field
and click on Accept it concatenates the text in the field with an
existing string and displays it on the web page. So I can submit a few
words one at a time and make a sentence. Clicking the Clear button
lets me start over.
-Carl Gundel, author of Liberty BASIC
Re: Simple stateful web page using Perl
This breaks down into four or five tasks.
(1) Handing the submission. Look at CGI.pm for reading form data.
(2) Deciding to append or clear. Only the clicked submit button will be
a successful control, so give them the same name and test the value on
(3) Storing the data. You can do this to a database (look at DBI and
possible DBIx::Class) or a flat file.
(4) Reading the data (as 3)
(5) If you want multiple users to have their own areas to work with,
then you need to identify the users. CGI::Session is probably a good
place to start.