2.1. More about semicolons

A perl program can naturally include more than one command. To do so, you need to place a semicolon at the end of each command or otherwise the interpreter will be confused.

It is not enough to put each command on a separate line. In fact it's not even necessary. The following two programs are equivalent:

print "One Fish,\n";
print "Two Fish,\n";
print "Red Fish,\n";
print "Blue Fish.\n";

and

print "One Fish,\n"; print "Two Fish,\n";
print "Red Fish,\n"; print "Blue Fish.\n";

However, for readability and easy debugging it is recommended that each statement will be on a separate line. And sometimes it's helpful to span one on more than one line.


Written by Shlomi Fish