Thursday, August 26, 2010

Introduction to perl

Perl is a script language which was originally developed by Larry Wall. The source code can directly be "executed" using perl and there is no explicit compilation step involved. This perl program is usually installed in /usr/bin/perl. Perl is in many aspects quite similar to the classic unix programs awk and sed but perl has gone a long way from there. Today you can even do object oriented programming and design graphical user interfaces with perl. Perl can easily be extended in its capabilities with libraries. The perl archive at CPAN has many of them. This first article will however not go into advanced topics. Instead I would like to show you some basics and have more advanced things in later articles.
Perl is a very useful scripting language. It is a universal tool for everyone with some programming skills.

A simple program


  1. #!/usr/bin/perl

  2. print "Hello World!\n";
When you click Run > Run or press F9, the program will launch and print the message “Hello World!”

Let's look at the program in more details.

The first line of the program is a special comment. Comments in Perl program start from the pound sign (#) to the rest of line. There is no sign for block comment. On UNIX systems, two characters #! starting in a line indicates the program is stored in the file /usr/bin/perl


The second line starts with print statement followed by a string “Hello World” and then followed by a semi-comma. Every Perl statement has to be ended with a semi-comma (;).

You can also launch Perl program by double click on the source code file. There is no *.exe or *.dll file when you write Perl programs. If you want to distribute Perl program just copy the source code to other.

No comments:

Post a Comment