Lesson 1: Perl script skeleton

Perl comes preinstalled on Macs and Linux distributions. It can be downloaded for PCs. Perl is widely used by biologists to solve problems we encounter when handling DNA and protein sequences, file format conversions, as well as many any other tasks that are computationally repetitive. Perl is not the only language for these tasks but one of many. Though, perl is my favorite!

Lesson 1: The skeleton of the perl script & Running a perl script from the command line

The skeleton of the Perl script.

  1. path to perl
    • 1
    • This can differ on different systems, or if you have a local or nonstandard installation of perl.
  2. allow for extensive reporting of warnings
    • 2
      #!/usr/bin/perl -w
  3. use the strict module
    • 3
      use strict;
    • using the strict library will help you to keep track of variable names and scope
  4. add comments
    • 4
    • a '#' pound or number sign indicates that the text that follows is a comment
    • comments are good to document logic, script names, and script purposes
  5. the body of you script that does something.
    • 5
      print "Hello! I wrote my first perl script!!\n";
    • each line of your script will end with a ';' semicolon.
    • print is a function.
    • '\n' is the newline character
    • Not used in this lesson but it is nice to know that '\t' is the tab character

Running a perl script from the command line.

  1. Make the script executable. (Note: I will use '%%' to indicate that we are on the command line. Do not type the '%%'.)
    • %% chmod +x yourScript.pl
  2. running it from the commmand line
    • %% ./hello.pl

Putting it all together

The complete script:

#!/usr/bin/perl -w
use strict;
print "Hello! I wrote my first perl script!!\n";

Running the script and the output:

%% ./hello.pl
Hello! I wrote my first perl script!!


  1. Write your first perl scirpt
    • use the format described above
    • use the print funtion