PERL for biologists

by Kurt Stüber

Introduction

This course is not intended to be a substitute for the study of the text books cited in my book list. You will not learn all available PERL commands, but only a small subset that should enable you to write small programs yourself. This is a PERL course for biologists since most my examples are taken from molecular or general biology. This will show biologists the value of writing own software and also how easy many tricky problems can be solved by a comparatively simple PERL code.

I wish you fun with the study of this course and invite you to send comments, complaints, encouragements, own solutions etc. to my email adress: stueber@mpiz-koeln.mpg.de.

Installation

In order to install PERL on your computer you might need the service of our computing support team or you might try to do it by yourself. PERL is a free language and can be installed on almost any computer in the world. You go to the webpage www.cpan.org, look for the correct binaries and start downloading. To assist you in your attempts I include here two videos that show how ActivePerl ist installed on a PC using Windows XP:

Most UNIX systems like Mac OSX and Linux already have PERL installed, so you do not need to take any action

How to start with PERL

To write PERL programs several special editors exists. But it is possible to write programs with any (most simple) text editor. My recommendation for Windows is the textprogram "WordPad". This is installed by default in any Windows. You find it by clicking on "Start" "All Programs" "Accessories/Zubehör" and finally "WordPad". The PERL programs have to be saved as "text only/Textdokument" NOT in the "Rich Text Format/RTF". You should save the program with the .pl file extension. If PERL is correctly installed, then you can start the program directly by a simple doubleclick.

There is a PERL editor from www.enginsite.com which you can download: Perl-Editor. The PERL editor can be bought or you can download a free version with a reduced number of functions which is nonetheless quite useable.

When programs are developed it rarely happens that a program is immediately finished and runs whithout complications. Programs have to be tested, even when they are not yet finished and even if they still contains errors (bugs). The removal of bugs from programs is called "debugging". A program with bugs often does not run at all, or dies with a short error message. When you start your program by doubleclicking then a new window opens (an "Eingabeaufforderung" or "Command prompt" Window). This window closes immediately when an error happens and gives you no opportunity to read the message. To avoid this you can call your PERL program directly from the "Commannd prompt/Eingabeaufforderung" window. You start the Command prompt from the "Start" button, "All programs", "Accessories/Zubehör". In the Command prompt you first change your directory to the place where your PERL program is stored. For this use the "cd" (change directory) command. Then enter "perl myprogram.pl" to start your program. After the program runs the command prompt window will stay and allows you to read the error message(s) and correct your program.


© Kurt Stüber 2007.