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:

  1. Instead of creating a page, you create a frameset with a parent frame, an invisible communication frame and the content frame.

  2. 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.

  3. 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.

  4. 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.

In reply to Re: dynamic update javascript & perl? by Thelonius
in thread dynamic update javascript & perl? by emilford

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.