Perl is a popular computer language used in many professions because of its easy to learn format. It has also become very popular in the field of bioinformatics. In this tutorial, I will show you one basic program, which will teach you how to start and run a Perl program.
Program: Bioinformatics is Fun
The main idea of this program is to show you how to create and run a Perl program on your computer. This is the line of code that you will enter in your chosen text editor. The most commonly used text editor is notepad.
print “Bioinformatics is fun. “;
The instructions for opening and creating this program are listed below according to the operating system.
1. Create a new folder in your C: drive, and name it perlbio. The directory for your file should be C:perlbio. Your program will be placed in this folder.
2. Open your text editor and enter the lines of code into your text editor.
3. Save the file as fun.pl. (Make sure the file is not saved fun.pl.txt!)
4. The file must be open in MS-DOS prompt to view the program. Open the MS-DOS prompt and type cd C:perlbio and then press return.
5. Then type fun.pl and press return.
6. This should be the correct result printed in the window: Bioinformatics is fun.
This information is an excerpt from Beginning Perl for Bioinformatics.
Save Perl programs as droplets as shown from the MacPerl documentation. The basic procedure to do this is as follows:
1. Open the Perl program with the MacPerl application.
2. Choose Save As
3. Select the Type option Droplet
Explanation for Program
Line #1: #!/usr/bin/perl -w
This line informs Unix that the file is a Perl program. Perl also reads this line to see if there is any special commands. For example, the -w command is turned on. This command causes warning reporting in the program.
Line #2: print “Bioinformatics is fun. “;
Line two, along with line three, is a statement. Just like a sentence ends in a period in the English language, a statement ends in a semicolon in Perl. There are many types of statements in Perl.
“Bioinformatics is fun. “;
This part of line #2 is called the string. A string is designated by quotes.
This is a command that Perl reads and responds to accordingly. The print command in this line is instructing Perl to print the string.
This is the new line of the second line. This instructs Perl to start a new line.
Line #3: exit;
The exit command tells the computer to exit the program.
Great job on completing your first Perl program!
Tisdall, James. Beginning Perl for Bioinformatics. 1st ed. Sebastopol, California: O’Reilly Media, Inc., 2001. Print.