next up previous contents index
Next: Data Structures Up: Introduction to Perl Previous: Contents   Contents   Index

Creating and running a perl program

In a text editor, type the program. The traditional example is ``Hello World''1.1.

    print "Hello World!\n";

The first line tells the operating system which program should run it, if the program has permission to execute. In perl everything after a # on a line is a comment.

The second line tells the computer to print out to the terminal the string in quotes. The ``\n'' is perl for ``Start a new line.''

Save it as ``''.

At a terminal prompt (in UNIX, the ``%'' or ``$'' or, in DOS, ``C:\>perlfi1'') type ``perl'' and then a return:

    % perl

The computer will print out:

    Hello World!

Tom Hunt 2002-06-09