Bookmark This Site

Intro to Perl - Starting

Author: Unknown
Submission Date: 2005-08-18
Website:
Email:
Keywords: Keywords Unavailable
Synopsis: Introduction to the popular Perl programming language. The preferred CGI language aswell as a great stand-alone.

Intro to Perl - Starting

Let's look at the "Hello World" program in Perl:

#!c:perlperl.exe
print 'Hello World';

#!c:perlperl.exe

This is the path to the perl interpreter on the system the program is being run on. On unix systems this line is compulsory as the system must know how to run the program. If you're using activestate perl with windows the path to perl is included in your "path" and including this line isn't compulsory. However it is always good practice to write all your perl programs starting with this line, you never know if you may have to move the script to a unix system, try to format your programs neatly and correctly, it makes things alot easier when you need to do some editing.

print 'Hello World';

The 'print' function is used in perl to print (doh) information to the screen. The function is used: print 'text to be printed';. Notice how the text to be printed is enclosed in single quotes. This isn't always so, but for now i'm not going to go into that until you know what a variable is, and how they work.

Also note that each line ends with a semi-colon(;). Every line in a perl program must end with a semi-colon. For certain commands that contain inside them other commands, this isn't so, but again, you don't need to know that just yet. Let's go on and look at variables.

Link to this article:
http://www.daremedy.com/tutorials/perl/tut-1124406248.html

[ ^Top ]    [ Go Back ]