What is Perl?
Perl is an interesting scripting language that attempts to bring together everything cool from all other languages (according to Larry Wall, the author of Perl). Perl has a religious-like following in the world of UNIX systems administrators, and is used for a wide variety of tasks. With the explosion of the World Wide Web, it was discovered that Perl could easily be used as a dynamic scripting side language for Web sites, and many dynamic Web sites running on UNIX platforms employ the use of many Perl scripts. If you ever visit a page with a
.pl extension, chances are
it is a Perl script.
To learn more about Perl, be sure to visit Perl.com.
OK, so What is PerlScript?
PerlScript is an ActiveX Scripting Engine put out by the good folks at ActiveState. From the ActivePerl Web site on ActiveState.com, you can download ActivePerl, which contains Perl for Win32, Perl for ISAPI, and, most importantly, PerlScript.
When using an ASP page, you can tie into any compliant ActiveX Scripting Engine. The one most commonly used is the VBScript ActiveX Scripting Engine. However, there is nothing to prevent you from using another server-side scripting language like PerlScript. Once you've downloaded and installed ActivePerl on your Web server, you can begin to use PerlScript in your ASP pages (note that you can also use PerlScript in your WSH scripts as well)! To do so, you need to include the following line of code on your ASP pages that you wish to use PerlScript:
Now, start writing PerlScript code! As with JScript, PerlScript is case sensitive. Furthermore, PerlScript uses
a prefix character to indicate the type of variable being used. For example, if you wanted to create a scalar
variable, you need to prefix it with a
$. (Scalar variables are variables that are not arrays or
associative arrays. An example of a scalar would be a string, and integer, or whatnot.) To declare variables,
use the keyword
my in place of the
Dim keyword in VBScript.
The ASP intrinsic objects are accessed by prefixing the object name with a
$. For example, to
output, "Hello, world!", you could do:
Each statement needs to end with a semicolon (similar to JScript). Note that rather than using a period to
access a method of an object (as in
Response.Write), an arrow is used (
slightly more involved ASP page follows:
Note that when using PerlScript, you simply place the variable name in the string. PerlScript will seach the
output string for words prefixed by a
$ and displays those as variables.
Now, this article wasn't intended as a tutorial for PerlScript. Rather, its intention was to inform you about the ability of using PerlScript as an alternative server-side scripting language.