Here is the basic perl program that we'll use to get started.
#!/usr/local/bin/perl
#
# Program to do the obvious
#
print 'Hello world.'; # Print a message
Each of the parts will be discussed in turn.
Every perl program starts off with this as its very first line:
#!/usr/local/bin/perl
although this may vary from system to system. This line tells the
machine what to do with the file when it is executed (ie it tells it
to run the file through Perl).
Comments can be inserted into a program with the # symbol, and
anything from the # to the end of the line is ignored (with the
exception of the first line). The only way to stretch comments over
several lines is to use a # on each line.
Everything else is a Perl statement which must end with a semicolon,
like the last line above.
The print function outputs some information. In the above case it
prints out the the literal string Hello world. and of course the
statement ends with a semicolon.
You may find the above program produces an slightly unexpected result.
So the next thing to do is to run it.