You may want to have a look at OpenThought. It's a Perl module (and framework) that lets you do the kind of things you're wanting. I haven't used it yet, but I gave it a good look-over, and here are my notes on what it does:
OpenThought allows a web page to be incrementally updated with data
from the server. You can change fields on a form, e.g., without sending
a whole new page.
How OpenThought works:
- Instead of creating a page, you create a frameset with a parent
frame, an invisible communication frame and the content frame.
- In the content frame, you can do anything you would normally do
with a normal page. In addition, to use OpenThought, you can add
JavaScript calls for any event, e.g.
onclick="parent.CallUrl('anopenthoughturl', form_element, ...)"
The javascript function CallUrl in the parent frame serializes the
data from the call and sends an HTTP request to an OpenThought
application at the specified URL, with the communications frame given
as the target for the HTTP response.
- The OpenThought application deserializes the data into a Perl data
structure. The application can them perform any computation. It
then creates instructions to modify the content frame. OpenThought
transforms these to javascript and returns the results wrapped in
<script></script> tags.
- When the communication frame receives the complete page, it
executes the script, which constructs a javascript data structure,
then calls a function in the parent frame. This function uses the
data structure to update the document in the content frame.
It's easier to use than this might suggest. | [reply] |
I couldn't have said it better myself :-)
As a heads up, apparently some of the tests in version 0.63 of OpenThought don't work as they should. So there may be issues with the 'make test' phase of the installation. Corrections to this are currently being put in CVS, and will (theoretically) work correctly in the next release.
Good luck!
-Eric
--
Lucy: "What happens if you practice the piano for 20 years and then end up not being rich and famous?"
Schroeder: "The joy is in the playing."
| [reply] |
I know how to do update dynamically using Javascript, but is it possible to use perl to grab the text contained within the specific file? Somehow pass the contents back to the Javascript?
Sure, but it takes a bit of hackery to get it working. Look at XML HTTP Request objects (external link). The XML is only used on the client side, so your CGI program won't need to parse the XML. IIRC, the CGI doesn't have to do anything special beyond what CGIs already do. The hoop-jumping happens on the client side.
Alternatively, you can have a tiny IFRAME that is refreshed by JavaScript and the text grabed out of that. This will probably work on more browsers than the XML Request, though I find it more asethetically pleasing than the IFRAME method.
| [reply] |
What you are describing sounds a lot like a weblog — you might want to look at Movable Type, which is a Perl-written blog that is powerful, easy to configure and ( very important ) easy to hack. It's the usual dilemma about what is faster - writing what you want from scratch, or learning something new and adapting it.
| [reply] |