| ActivePerl User Guide |

# PerlScript

- What is PerlScript?
- What do I need to run PerlScript?
- How do I install PerlScript?
- Why aren't my event handlers called?
- What is Windows Script Host?
- Can I write Active Server Pages with PerlScript?
- What can I do when PerlScript in ASP seems capsized in PWS?
- What is Global.asa to ASP and PerlScript?
- Client-side PerlScript
- How can I configure client-side PerlScript security?
- Other References

## What is PerlScript?

PerlScript is an ActiveX scripting engine that allows you to use Perl with any ActiveX scripting host. At this time, ActiveX scripting hosts include:

- Internet Information Server 3.0/4.0/5.0
- Peer Web Services 3.0/4.0
- Microsoft Internet Explorer 5.0x
- Windows Scripting Host

## What do I need to run PerlScript?

- ActivePerl
- an ActiveX scripting host (see above)
- Windows 2000/NT/9x
- Perl scripts!

## How do I install PerlScript?

When you launch the ActivePerl installer, PerlScript is one of the components you can optionally install. You must install, or have previously installed, ActivePerl to use PerlScript.

## Why aren't my event handlers called?

Case sensitive lookup of event names may be being performed. Event name lookup can be made case insensitive by adding key

HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlScript\1.0
REG_DWORD: NoCaseCompare = 1 (default)

## What is Windows Script Host?

Microsoft advertises Windows Script Host, or WSH for short, as being "a language-independent scripting host for 32-bit Windows operating system platforms". WSH offers a lot to VBScript and JScript developers for whom console type programs have been traditionally difficult. For Perl Developers, however, the same functionality can be found with a Perl module or extension.

More information can be found in the Windows Script Host tutorial.

## What do I need to write Active Server Pages with PerlScript?

Active Server Pages, or ASP for short, is a server-side technology that enables you to embed script commands within HTML. ActivePerl and PerlScript are required on the server that is providing the webpages, but the two are not required on the client; however, would you be developing Active Server Pages on your local machine, you are, of course, both the client and the server.

For a web server, Windows 95 users will need the Personal Web Server (PWS), which is freely downloadable as a component included in the NT Option Pack available from Microsoft.

Windows 98 users will need to either install it from the CD that comes with Windows 98 or download the NT Option pack. Windows NT/2000 users will either get it installed out of the box under the name Internet Information Services or need to install it off from the CD.

For more information about how to use the technology, see the Active Server Pages tutorial.

## What can I do when PerlScript in ASP seems capsized in PWS?

There are three widely used solutions when PerlScript and ASP doesn't function the way it should in PWS. First, reboot the computer and see if it works; next, reinstall ActivePerl with PerlScript checked and see if it works; lastly, reinstall PWS if none of the above works. Oftentimes, when somebody has a problem with PWS, it is commonly asked if the person has set "scripts" permissions on the server so that a scripting language is enabled to run. PWS and IIS sets the majority, if not all, virtual directories to allow scripts by default, so do not worry yourself about that; instead, follow the guidelines laid out above.

## What is Global.asa to ASP and PerlScript?

Global.asa is a file that exists for each IIS application. On PWS, there is only one IIS application while later versions of the IIS web-server supports many more IIS applications. Global.asa can be used to declare objects that are given either Session or Application scope within the web service. It must as a skeleton without code look as follows:

`<script language=perlscript runat=server>
sub Application_OnStart {
}
sub Application_OnEnd {
}
sub Session_OnStart {
}
sub Session_OnEnd {
}
</script>`

Then you can put code within the subroutines that creates variables, objects, and so forth. The subroutines, or events, will be called at their designated times: Session_OnStart when a new session is started, and its OnEnd event is run when the session is ended. The Application's start and end signifies the start and stop of the webserver.

## Client-side PerlScript

Client-Side PerlScript has Perl embedded within your HTML documents. All PerlScript code must be contained within `<SCRIPT LANGUAGE="PerlScript"> </SCRIPT>`

Client-side PerlScript has the added requirement that both ActivePerl and PerlScript be installed on each computer will will be loading PerlScript pages.

Client-side Perlscript should only be used if you can control the ocnfiguration of the computers on which it will be run. If your goal is build an application which will be used by a large number users, Server-side PerlScript is considerably more practical.

To display something to the browser, use the `write()` method of the document object. You can use the `write()` method with `$windows->document->write('any old text')`.

The sample below is another Hello World variation, but this time using client-side PerlScript:

`<HTML>
<HEAD>
<TITLE>PerlScript Hello World!</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<h2>PerlScript Hello world!</h2>
<SCRIPT LANGUAGE="PerlScript">
$window->document->write('Hello world!');
</SCRIPT>
</BODY>
</HTML>
`

## How can I configure client-side PerlScript security?

PerlScript in IE 4.0 and higher can be enabled/disabled by zones

HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlScript\1.0
REG_DWORD: EnabledZones = 0x0010 (default)

Values

- Enable All 0x0001
- Enable Local 0x0010
- Enable Internet 0x0020
- Enable Trusted 0x0040
- Enable Restricted 0x0080 (for the perverse)

IE3 is more limited; it is an all or nothing affair. For IE3 the only values recognized are

Values

- Disable All 0x0000
- Enable All 0x0001

## Other References

Another PerlScript FAQ available on the net can be found at:

- The Perl-Win32-ASP FAQ. Maintained by Matthew Sergeant.

PerlScript