Perl, Testing, and Web Programming

Perl used to be one of my favorite languages for performing test automation. Perl is available on most platforms, has been around for a long time, and has extensive libraries that have all kinds of functionality such as HTTP requests. I don’t use Perl very much anymore. Perl has fairly tricky syntax which makes development time a bit longer than with more modern languages such as C# and PowerShell. Anyway, I was putting together an introduction to Perl class last week and discovered a couple of things about Perl and Web programming that I didn’t know before. Namely, you can use Perl (instead of the usual VBScript) to create ASP pages on the server side, and you can use Perl on the client side too. Sort of anyway. The trick is that you really have to use something called PerlScript, which is a kind of set of extensions to the Perl language. PerlScript comes from ActiveState, the most common version of Perl used on Windows based systems. Here’s an example of PerlScript used to create an ASP page:
<%@ Language="PerlScript" %>
<h3>ASP with PerlScript Example</h3>
  $t = localtime
  $Response->write("This page created at $t");
Pretty cool. You can also use PerlScript on the client side (instead of the usual JavaScript) too. For example:
<script language="PerlScript">
 sub putMessage {
  $window->document->myForm->Text1->{’value’} = "Hi";
 <form name="myForm">
 <input type="text" id="Text1" />
 <input type="button" onclick="putMessage();" />
Also pretty cool but not terribly useful because the technique requires PerlScript on the client. Anyway, Perl is a very flexible language and it’s amazing what you can do with it.
This entry was posted in Software Test Automation. Bookmark the permalink.