Getting Started with Perl
Table of Contents
Install Perl
You need to install Perl \(\geq\) 5.10 on your machine.
For OS X and Linux, Perl is already installed. Head to the next section.
For Windows, you can install one of these free packages:
- Strawberry Perl (the portable edition is great for your lab machine)
- ActiveState Perl Community Edition
Running Perl
Type perl -v
on your computer to ensure it works.
OS X
- Hit
Cmd+SPC
and enter "Terminal" in Spotlight, or openApplications/Utilities/Terminal.app
- Enter
perl -v
and pressRET
Windows
- If you installed the portable edition, navigate to the extracted
folder and double-click
portableshell.bat
(if you installed the full edition, findportableshell
in your Start menu) - Enter
perl -v
and pressENTER
Linux
- Open your terminal (i.e., xterm, terminator, GNOME Terminal, etc.)
- Enter
perl -v
and pressRET
Setup your text editor
You need a plain-text editor to edit Perl files. Microsoft Word, Apple Pages, or TextEdit will not work. Here are some suggestions, but feel free to use other text editors (Google "free text editor +Windows")
Create your first program
- In your new text editor, create a new file called
hello.pl
- Paste the following contents in:
print "Hello, World!\n";
- Save the file to your desktop
- Open your terminal/shell and change to the folder containing your
script. Use the
cd
("change directory") command for this:- OS X and Linux
cd ~/Desktop
- Windows
cd %UserProfile%\Desktop
- Run the script:
perl hello.pl