This article outlines the steps for installing and configuring Perl on OS/2 Warp 4 and Warp 4 Server. Of course it may work on other versions of OS/2 with other fixpaks, but was not tested for this article. ALWAYS be sure to back up the system before making any changes! The author is not responsible for any damage to the system resulting from the installation of Perl.
There are two ways to install Perl on OS/2: Manually or SoftInstaller. The remainder of this article will describe the installation using SoftInstaller included with the Perl packages that were downloaded. Unzip the files plINSTAL.zip and plinstl0.zip in the temporary directory where they were downloaded. This will be the installation directory containing all the zip packages. Once unzipped run the install.exe program file.
The O'Reilly (http://www.oreilly.com) camel associated with Perl appears on the screen with some brief instructions. Click continue to proceed. A dialog will appear prompting to update config.sys once the installation is complete. The README.1st file warns that SoftInstaller will change a chunk of the config.sys file to upper case which can cause problems for case sensitive entries. In order to save the modified copy to another file for review, uncheck the box. The modified file will be saved as config.add. You may wish to allow the program to update the config.sys for you, but do so at your own risk.
The next dialog box gives the list of all packages downloaded for installation. Select All and read the descriptions. The one package that may not be needed according to the descriptions is Perl a.out-style executable since this only works on DOS and Win (though may run under an OS/2 DOS window). The manpages are handy if running XFree86/2.
Be sure to review/edit the install paths. Make sure that the drive selected is valid and preferably the OS/2 installation drive. Some of the default paths (make sure they are correct!) place some libraries in the EMX directory. This is handy since it reduces the paths added to $PATH and $LIBPATH. This can be a problem if the EMX directory tree ever needs to updated or removed. The author used this structure:
Once all modifications are made to satisfaction, click on the install button. Approximately 19 Megs will be needed for the full installation. A dialog box appears showing the status and files being copied. This will take about 5-10 minutes depending on the machine. An OS/2 command prompt appears and executes a script to test the installation. A response indicates the success of the install.
If you chose to save the modified config.sys into a separate file, then compare the new file with the original and check for changes. Noticeable changes that should have been made is the addition of the following lines:
set PERL_BADLANG=0
set PERLLIB_PREFIX=f:/perllib/lib;C:\EMX\PERLLIB\LIB
set PERL_SH_DIR=C:\EMX\BIN
Double check for any other changes if the installation method varied from above. Copy these to the config.sys file, OR rename the original to config.perl and rename config.add to config.sys. Reboot the computer. If all went well, Perl should be fully functional.
In order for a Perl script to execute, every script must be told to use an external batch processor other than the OS/2 batch processor. This is done by placing the following line at the start of every script:
extproc perl -S
This has the same effect as unix #!/usr/local/bin/perl. In order to execute the script from a command line, the file extension will need to be 'cmd'. This is also different from the typical unix naming convention using 'pl'. So a program named perlscript.pl under unix, will be named perlscript.cmd under OS/2. Other OS/2 specific syntax structures can be found in the documentation installed with Perl (you did install it, right?)
This should give the tools needed to perform system administrative tasks on OS/2 such as scripted log rotating. Of course, Perl is not limited to just system administration, but can be used for many other tasks such as data manipulation or cgi scripting as well. Setting up Perl for Web development on OS/2 is discussed below.
There are a few specific details relating to cgi scripting support. Make sure your httpd.conf file contains a line that calls the cgi module. It should look something like this:
LoadModule cgi_module libexec/cgi.dll
This should be a default entry in the configuration file. Make sure there is an entry that sets the location for cgi scripts which is commonly called cgi-bin. There should be a line that looks like this:
ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"
This entry is specific to the installation of apache. Edit it accordingly. There is one more entry to check. It should look something like this:
<Directory "/home/httpd/cgi-bin">
AllowOverride None
Options None
Order allow.deny
Allow from all
</Directory>
Be sure to edit this according to the specific Apache install as well.
print "Content-type: text/html\n\n";
Here is a summary example that combines a simple Perl script that opens a directory, assigns file names to an array, closes the directory, then prints the contents, with hyper links, to the web browser. Yes, it does work. (-=
extproc perl -S
#
# perlCGI_test.cmd
#
# This script tests Perl as a CGI for Apache on OS/2.
#
# Brent R. Scott
print "Content-type: text/html\n\n";
print "This is a test of Perl as a CGI under Apache for OS/2.<BR>";
opendir(WEBDIR,"/home/httpd/html");
@files = grep (/\.gif/, readdir(WEBDIR));
$fcount = @files;
closedir WEBDIR;
print "Number of files found: ", $fcount, "<BR>";
for ($i = 0; $i < $fcount; $i++ ) {
print "File in position ", $i+1, " <A HREF=\"/$files[$i]\"> ", $files[$i], "</A><BR>\n";
}
During personal time, he and his wife enjoy playing music together (violin and
piano) as well as doing home improvement projects on their house on the weekends.
This article is courtesy of www.os2ezine.com. You can view it online at http://www.os2ezine.com/20020416/page_6.html.