|
Here is the basic perl program that we'll use to get started.
#!/usr/bin/perl
#
# Program to do the obvious
#
print 'Hello world.'; # Print a message
Each of the parts will be discussed in turn.
The first line
Every perl program starts off with this first line:
#!/usr/bin/perl
This line may vary from system to system. This line tells the machine that the script is a perl script and that also where to find the perl binary file. If you are not sure where your perl binary file is you can run the following command at the shell prompt:
which perl
The output from this will show you where your perl binary file is.
Comments
Any script is only as good as its documentation. A script which is not properly documented is useless when it breaks! All good scripters will enter plenty of comments and notes in their work. to enter a comment you need to start the line off with a #
Printing Output
The print function outputs some information. In the above case it prints out the the literal string Hello world. 
|