Server-Side PerlScript

PerlScript on the server-side of business is a much more viable method of incorporating Perl into your web applications. You can use PerlScript as the scripting language for Active Server Pages (ASP), which are used by such applications as Microsoft’s IIS and O’Reilly’s WebSite Pro. See the documentation for these products to properly set up ASP on your server. ActivePerl with PerlScript must be installed on the server machine to be used with ASP.

Active Server Pages use PerlScript in pages much like client-side scripting except that the object model is different, and most importantly, the script is executed on the server. When an Active Server Page is requested, the .asp file is processed, scripts are executed, and an HTML page is produced and delivered to the client.

Each script is contained within <SCRIPT> tags. PerlScript must be declared as the default scripting language for each file with:

<SCRIPT LANGUAGE="PerlScript" RUNAT=Server>

The RUNAT attribute signals that the script is to be executed on the server and not the client. The lines of the script follow, and the script is closed with an ending </SCRIPT> tag.

An alternative syntax to the <SCRIPT> tags are the <% %> delimiters. These are not HTML tags, but indicate that whatever happens between them is to be executed. There are also special constructs used with these delimiters. Since they can be interspersed with HTML throughout a file, the default language must be declared at the top of the file ...

Get Perl in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.