Getting Started with Perl

 

Windows

 

Download and Installation

- Download ActivePerl, the MSI version for Windows.

- If you're running Windows NT or 2000 make sure you're logged in as the administrator or have administrator privileges.

- Install ActivePerl by double-clicking.

 

Writing Perl Scripts

- Perl scripts can be written using any text editor (e.g. Notepad, Microsoft Word)

- We recommend an inexpensive text editor called Editplus which automatically color-codes your scripts, making them easier to read, write, and troubleshoot.

- When using Word be sure to save your scripts as plain text and end the file name with the ".pl" extension.

- When using Notepad filenames should also end with the ".pl" extension.

- All perl scripts begin with the following line "#!/usr/bin/perl"

- Cut and paste the following two lines into your editor and save it according to the above instructions.
This is the "Hello, World" program for Perl.

 

#!/usr/bin/perl

print "Hello, World...\n";

 

Running Perl Scripts

- Open a MS-DOS command line window by going to the Start menu and selecting programs -> accessories -> command prompt.

- Go to the directory (folder) where you saved your perl script by using the "cd" command.
Example: To go up one directory type "cd ..
This might get you from "c:/my_files/my_perlscripts" to "c:/my_files/".
To go down a directory, let's say from "c:/my_files" to "c:/my_files/my_perlscripts" type "cd my_perlscripts".

- Once you are in the same directory as the perl script you'd like to run, type "perl script_name".
In some systems (esp. NT and 2000) you can leave off "perl" and just type the name of the script.
If the script ends with the ".pl" extension the system will recognize it as a Perl script.

- The script should start running in the MS-DOS window.

- Try running the Hello, World program given above.

 

What next?

- Check out the One Hour Perl tutorial for a set of well-annotated sample scripts which introduce many of Perl's basic functions.
Also take a look at the Perl resources (books and links) given on the course readings page.