Type in the example program using a text editor, and save it. Emacs is a good editor to use for this because it has its own Perl mode which formats lines nicely when you hit tab (use `M-x perl-mode'). But as ever, use whichever you're most comfortable with.
After you've entered and saved the program make sure the file is executable by using the command
chmod u+x prognameat the UNIX prompt, where progname is the filename of the program. Now to run the program just type any of the following at the prompt.
perl progname ./progname progname
If something goes wrong then you may get error messages, or you may get nothing. You can always run the program with warnings using the command
perl -w prognameat the prompt. This will display warnings and other (hopefully) helpful messages before it tries to execute the program. To run the program with a debugger use the command
perl -d progname
When the file is executed Perl first compiles it and then executes that compiled version. So after a short pause for compilation the program should run quite quickly. This also explains why you can get compilation errors when you execute a Perl file which consists only of text.
Make sure your program works before proceeding. The program's output may be slightly unexpected - at least it isn't very pretty. We'll look next at variables and then tie this in with prettier printing.