We're about to create our first, simple Perl script: a "hello world" program. There are a couple of things you should know in advance:
Perl programs (or scripts --- the words are interchangeable) consist of a series of statements
When you run the program, each statement is executed in turn, from the top of your script to the bottom. (There are two special cases where this doesn't occur, one of which --- subroutine declarations --- we'll be looking at later today)
Each statement ends in a semi-colon
Statements can flow over several lines
Whitespace (spaces, tabs and newlines) are ignored most places in a Perl script.
Now, just for practice, open a file called hello.pl in your text editor. Type in the following one-line Perl program:
print "Hello, world!\n"; |
This one-line program calls the print function with a single parameter, the string literal "Hello, world!" followed by a newline character.
Save it and exit.