Cloudbook: Perl for Biologists

  1. Home
  2. Overview
  3. Perl
  4. § 2 open the video (pop-up)→
Statements

LivePerl

Lesson synopsis

In this lesson we will learn about statements. The print command will be used to demonstrate statements. Statements are separated by semicolon characters. A sequence of strings to print, separate by commas, will all be printed one after the other. A statement, or a comma, does cause the printing to be on multiple lines. To get a new line, a special two character sequence, "backslash n" must be used.

Here is the code that you are asked to type into the Liveperl window, and run, by the video instruction.

#!/usr/bin/perl -w

# print is a perl builtin function
# It prints strings.

print "This is a single statement.";
print "Look, ", "a ", "list!";

# The ';' character separates statements

print "This is "; print "two statements.\n"; print "But this ",
  "is only one statement.\n";