Here's a little ajax one I just put together. Enjoy!
#!/usr/bin/perl -w use strict; use CGI; use CGI::Ajax; use Storable qw/lock_store lock_retrieve/; our $file = '/tmp/messages'; our $MAX_MESSAGES = 10; our $table = eval { lock_retrieve($file) } || {}; my $cgi = new CGI; my $pjx = new CGI::Ajax( 'do_chat' => \&do_chat ); print $pjx->build_html( $cgi, \&show_page); sub do_chat { my ( $name, $msg ) = @_; if ( $name && $msg ) { push @{ $table->{messages} }, [ $name, $msg ]; shift @{ $table->{messages} } while @{ $table->{messages} } > $MAX_MESSAGES; lock_store $table, $file; } return join "\n", map "[" . $cgi->escapeHTML($_->[0]) . "] : " . $cgi->escapeHTML( $_->[1] ), @{ $table->{messages} }; } sub show_page { return $cgi->start_html( -onload => q{setInterval( 'do_chat( [],[\\'result\\'] ) +',1000 );} ) . $cgi->pre( { id => 'result' }, " " ) . $cgi->textfield( -name => 'name', -size => 10, -value => 'name', -id => 'name' ) . $cgi->textfield( -name => 'msg', -size => 50, -value => 'message', -id => 'msg' ) . $cgi->submit( -name => 'speak', -value => 'speak', -onclick => q{do_chat( ['name','msg'],['result'] );} ) . $cgi->end_html; }

In reply to Re: chatterbox like server app by bduggan
in thread chatterbox like server app by hushhush

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.