of available updates for Ubuntu.
You can determine what version of Perl you have installed by typing perl -
v at a shell prompt. When you install the latest Ubuntu distribution, you
should have the latest version of Perl that was available when the software for
your Ubuntu release was gathered and finalized.
A Simple Perl Program
This section introduces a very simple Perl program example to get you started
using Perl. Although trivial for experienced Perl hackers, this short example is
necessary for new users who want to learn more about Perl.
To introduce you to the absolute basics of Perl programming, Listing 46.1
illustrates a simple Perl program that prints a short message.
LISTING 46.1 A Simple Perl Program
Click here to view code image
#!/usr/bin/perl
print 'Look at all the camels!\n';
Type in the program shown in the listing and save it to a file called
trivial.pl. Then make the file executable by using the chmod command
(see the following sidebar) and run it at the command prompt.
COMMAND-LINE ERROR
If you get the message bash: trivial.pl: command not found
or bash: ./trivial.pl: Permission denied, you have either
typed the command line incorrectly or forgotten to make trivial.pl
executable with the chmod command, as shown here:
Click here to view code image
matthew@seymour:~$ chmod +x trivial.pl
You can force the command to execute in the current directory as follows:
Click here to view code image
matthew@seymour:~$ ./trivial.pl
Or you can use Perl to run the program, like this:
Click here to view code image
matthew@seymour:~$ perl trivial.pl