Friday, July 24, 2009

Simple Perl Programme

Perl Tutorial: A basic program


Here is the basic perl program that we'll use to get started.

#!/usr/local/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 as its very first line:
#!/usr/local/bin/perl
although this may vary from system to system. This line tells the machine what to do with the file when it is executed (ie it tells it to run the file through Perl).


Comments and statements

Comments can be inserted into a program with the # symbol, and anything from the # to the end of the line is ignored (with the exception of the first line). The only way to stretch comments over several lines is to use a # on each line.

Everything else is a Perl statement which must end with a semicolon, like the last line above.


Simple printing

The print function outputs some information. In the above case it prints out the the literal string Hello world. and of course the statement ends with a semicolon.

You may find the above program produces an slightly unexpected result. So the next thing to do is to run it.

1 comment:

  1. How to Play Pai Gow Poker | BetRivers Casino - Wolverione
    Pai Gow Poker is novcasino an online version of a https://jancasino.com/review/merit-casino/ traditional table game in which players 바카라사이트 place bets in the background. Pai worrione.com Gow apr casino Poker uses only the symbols from a

    ReplyDelete