PerlScript


  • What is PerlScript?
  • What do I need to run PerlScript?
  • How do I install PerlScript?
  • How can I configure PerlScript security?
  • Why aren't my event handlers called?
  • What is Windows Scripting Host?
  • Can I write Active Server Pages with PerlScript?
  • Client-side PerlScript
  • 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
  • Peer Web Services 3.0/4.0
  • Microsoft Internet Explorer 4.0x
  • Windows Scripting Host


    What do I need to run PerlScript?

  • Perl for Win32 Core
  • an ActiveX scripting host (see above)
  • Windows NT/95
  • Perl scripts!


    How do I install PerlScript?

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


    How can I configure PerlScript security?

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

      HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlSE\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


    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\PerlSE\1.0
      REG_DWORD: NoCaseCompare = 1 (default)


    What is Windows Scripting Host?

    Microsoft advertises Windows Scripting 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 on Windows Scripting Host can be found on the Microsoft Web Site at: http://www.microsoft.com/scripting/.


    Can I write Active Server Pages with PerlScript?

    Active Server Pages, or ASP for short, generate HTML on your Web server and send it to the browser. Perl for Win32 and PerlScript are required on your server but they are not required on the clients.

    To identify server-side Perl code to the server, you must do one of the following:

  • use the <SCRIPT> tag

    or

  • wrap your code in <% and %>

    The example below uses the <SCRIPT> tag.

      <%@ LANGUAGE = PerlScript %>
      <HTML>
      <HEAD>
      <TITLE>PerlScript Hello World!</TITLE>
      </HEAD>
      <BODY BGCOLOR="#FFFFFF">
      <H1>PerlScript Hello world!</H1>
      <P>
      <SCRIPT LANGUAGE="PerlScript" RUNAT=Server>
      $Response->write("Hello world!");
      </SCRIPT>
      </BODY>
      </HTML>
    To do the same by wraping your code in <% and %>:
      <%@ LANGUAGE = PerlScript %>
      <HTML>
      <HEAD>
      <TITLE>PerlScript Hello World!</TITLE>
      </HEAD>
      <BODY BGCOLOR="#FFFFFF">
      <H1>PerlScript Hello world!</H1>
      <%
      $Response->write("Hello world!");
      %>
      </BODY>
      </HTML>
    The first line of the script, <%@ LANGUAGE = PerlScript %> tells the server that you are using PerlScript, rather than any of the other scripting languages supported by Active Server Pages.

    Another option is enclosing anything that you want to be displayed as HTML as follows:

      <%= $hello %>

    This will display the value of the variable $hello.


    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 Perl for Win32 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">
      <H1>PerlScript Hello world!</H1>
      <SCRIPT LANGUAGE="PerlScript">
      $window->document->write('Hello world!');
      </SCRIPT>
      </BODY>
      </HTML>


    Other References

    Here's a short list of PerlScript FAQs available on the net:

  • The Perl-Win32-ASP FAQ. Maintained by Matthew Sergeant.
  • ASP/PerlScript FAQ at perlscript.rajiv.net. Another PerlScript FAQ. Maintained by Rajiv Kukreja .

  •     PerlScript