CGI and Perl

Executing Perl as a Helper Application

The other way to execute Perl scripts from the Net on your client is via the use of a MIME type, mapping to a helper application. Under UNIX you need to coordinate the tow files, .mime.types, and .mailcap in order to correctly map the URL's type to the Perl application.

Now the easiest, and the most dangerous, way to implement this is with the simple entry in your .mailcap:

application/Perl; /usr/local/bin/Perl %s

And in your .mime.types:

type=application/Perl\
 desc="Ordinary Perl script" \
 exts="myplt"

The perl-opengl plugin page
Figure 15.2. The perl-opengl plugin page.

These will map any URL with the .myplt extension to be executed automatically with Perl. Now that we've told you how to do it, we emphasize that you should never, ever do this, under any circumstances. Even using the special extension, .myplt, if anyone ever learns that you've set this up, they might be able to send you a script that could compromise your security in the guise of an innocuous-looking URL. Fortunately, Netscape nowadays has the built-in warning dialog, which prompts you before actually executing the script.

In any case, it's much better to use the Safe extension to set up a secure environment first, then execute the script within this environment. Listing 15.1 shows a simple script called HelperAppPerl that you can install and then set up your .mime.types and .mailcap files to invoke it with the Perl script you've downloaded.