Appendix 3

Appendix 3 

On Portability

Perl and most of its modules are available for free for many different platforms. Whether you want to run Perl on versions of Unix, DOS, versions of Windows, or MacOS, Perl is available. On Unix, Perl is run from the command line. It is usual for a Perl script to have a line such as

 

#!/usr/bin/perl

 

the first line of code on a Unix machine. This is a feature of Unix that allows the programmer to tell the system where to find the Perl interpreter that is going to execute the code. This line is actually a comment and must start on the first column. If on your system, Perl is not at /usr/bin/perl and is somewhere else, you must write the correct address here.

In Unix, before a Perl script can be run, the script must be made executable. It can be done by typing:

 

%chmod u+x progamfile

 

Here programfile is the actual name of the file that contains the Perl script. Once the file containing the script has been made executable, it can be run by typing in the name of the file containing the script. If the file is not made executable, one can still run it by typing

 

%perl scriptfile

 

assuming Perl is available on the operating system path variable and scriptfile is the name of the file where the Perl script is stored.

On DOS and Windows systems, Perl also runs from the command line. You simply type in the Perl script file name and it will run. The extension of the Perl program (say, pl) will have to be associated with the Perl executable to be able to do so. Otherwise, something like

 

%perl scriptfile

 

should work.

On Macintosh systems (Mac OS 9 or lower), Perl has a graphical interface. Perl programs can be run on such a system by choosing the appropriate menu item. On Mac OS X or Mac OS X Server, Perl can be run from the command-line like any other Unix system.

Since underlying processes of an operating system vary from platform to platform, the process facilities of Perl may not work the same way on all systems.