Print

Print


On Aug 28, 2005, at 11:35 AM, Eric Lease Morgan wrote:
>   <!cript type='text/html' src='http://foo/bar.cgi' />

If you meant "text/javascript" then this could work if your Perl
program bar.cgi generated JavaScript. If all you want to do is allow
people to drop that in their HTML and magically get a HTML
interjected into their page you could have your Perl script emit
JavaScript that performs a bunch of document.write() commands for the
HTML you want them to have:

     #!/usr/bin/perl
     use strict;
     use DirHandle;

     print <<JAVASCRIPT;
     content-type: text/javascript

     document.write('<h1>contents of /usr/local</h1>');
     document.write('<ul>');
     JAVASCRIPT

     my $dir = DirHandle->new('/usr/local');
     while (my $file = $dir->read())
     {
         print qq(document.write('<li>$file</li>');\n);
     }

     print qq(document.write('</ul>'););

If you want a more elegant (and involved) solution you might want to
explore creating a little JavaScript lib which your users could
import, and a function for them to call when the want to generate the
content. You could then have this function perform an XMLHttpRequest
back to a server side program (Perl, whatever) for the content, which
it then parses and modifies the DOM appropriately with the new content.

This is part of the AJAX equation that has lots of references on the
Internets.

//Ed