| Previous | Next
The PerlPlus Browser Plug-inNow we'll briefly examine Frank Holtry's PerlPlus Plug-in, a loadable Netscape extension that executes Perl programs on a client computer. The Perl programs themselves can exist anywhere on the Net-the mere act of browsing a PerlPlus program (or any page with an HTML Netscape publishes an API for C language plug-ins that describes how to register a plug-in instance, read streaming data from a browsed URL, access system services, and so on. In 1996, Stan Melax used these specifications and developed the first plug-in for the Perl world so he could run Perl OpenGL programs in a browser. Basically, Stan's plug-in would read the browsed OpenGL program, wrap it in a Safe module, and feed the result to Perl. The Safe wrapper code provided security, and passed window information to the OpenGL code so it could properly embed itself within the browser. In 1999, Frank rewrote the plug-in with an eye toward enhanced security. His idea was to use the Opcode module and restrict the opcodes available to the browsed Perl program. It's a multilevel scheme, from no security, in which all Perl opcodes are legal, to high security, where so many opcodes are forbidden that only the simplest Perl programs can run. Furthermore, a CGI program must first validate the browsed URL and return its opcode security level, a single digit from 0 through 5. The security CGI might be as crude as this simple table lookup:
Because the plug-in security model is under review, we won't examine this subject further. As it happens, Perl/Tk programs generally have to run with most opcodes enabled, so browsing untrusted PerlPlus/Tk programs is a major security risk; imagine unleashing the full power of Perl inside your browser![65] Nevertheless, it's easy to imagine a trusted environment where you know that the served PerlPlus programs are nonlethal.
Embedding Perl/Tk in Other WindowsTk Toplevels, including the MainWindow, have an optional -
In our case, the PerlPlus plug-in makes Netscape's window ID available via a qualified Perl scalar,
And here is what the file /tmp/ppl.log shows us: display : 148717568 version : 0.95.04 x_len : 666 x_min : 0 xwindow_id : 88081995 y_len : 272 y_min : 0 The Embedded Versus Full-Screen ModeFigure 22-5 depicts a full-screen Towers of Hanoi[67] simulation. A PerlPlus/Tk program runs in full-screen mode when its URL is browsed directly. In this case, your Tk program has an entire window all to itself.
Figure 22-5. Full-screen Towers of Hanoi programThe other way to invoke a PerlPlus/Tk program is via an HTML <BODY> Countdown to 2038, <EMBED src="y2k.ppl" width=225 height=50> although there's not much hope I'll be around for the event! </BODY> This code produced Figure 22-6, a Perl/Tk program constrained to a 225 x 50 window. Figure 22-6. A constrained, embedded Perl/Tk windowFor an embedded Perl/Tk window,
How You Can Contribute to the PerlPlus Plug-in ProjectThe PerlPlus plug-in is available for public download and development at http://sourceforge.net/projects/PerlPlusPlugin. Head to Sourceforge; get yourself a username and password; ensure you have an environment that includes SSH, SSL, and CVS; and you're all set to web-over to the CVS repository to examine the source and get the entire source distribution or diffs of various versions, all from within your favorite browser. If you want to work on the plug-in, contact Frank Holtry via the Sourceforge page, and he'll add you as a developer. Here's a sample CVS command to check out the source distribution: export CVS_RSH=/path-to/ssh cvs -z3 -dYOURNAME@cvs.PerlPlusPlugin.sourceforge.net:/cvsroot/PerlPlusPlugin co PerlPlusPlugin If you're behind a firewall, you'll need an SSH wrapper such as this, or else your CVS commands will appear to hang: #!/bin/bash exec /usr/local/bin/ssh -P $* The |