1. Technology

Testing your Perl installation

Your first Perl program

By

In order to test our fresh installation of Perl, we'll need a simple Perl program. The first thing most new programmers learn is how to make the script say 'Hello World'. Let's look at a simple Perl script that does just that.
 #!/usr/bin/perl
 print "Hello World.\n";
 
The first line is there to tell the computer where the Perl interpreter is located. Perl is an interpreted language, which means that rather than compiling our programs, we use the Perl interpreter to run them. This first line is usually #!/usr/bin/perl or #!/usr/local/bin/perl, but depends on how Perl was installed on your system.

The second line tells the Perl interpreter to print the words 'Hello World.' followed by a newline (a carriage return). If our Perl installation is working correctly, then when we run the program, we should see the following output:

 Hello World.
 
Testing your Perl installation is different depending on the type of system you are using, but we'll take a look at the two most common situations:
  1. Testing Perl on Windows (ActivePerl)
  2. Testing Perl on *nix Systems
  1. About.com
  2. Technology
  3. Perl
  4. Getting Started
  5. Learn How to Test Your Perl Installation

©2014 About.com. All rights reserved.