[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
BeginnersGuideToPerl

Beginners Guide To Perl

What Is Perl?

Perl first appeared in 1987, created by Larry Wall. Perl stands for Practical Extraction and Report Language, and this describes its key strengths well - obtaining data, manipulating it and delivering it. Perl is interpreted, however the creation of a binary is possible. Today Perl is shipped as standard with most UNIX and Linux distributions, but has been ported to run on almost every platform there is, including Windows. Perl is distributed under the GNU Public License.

What Can Perl Be Used For?

A common use of Perl today is in writing CGI scripts. These are scripts that take input, e.g. from a form on a web page, process it in someway (maybe save it in a database or file, or do some calculations on it), and finally produce a page of HTML code on the fly. This allows you to create dynamic content sites. Under a UNIX/Linux shell, Perl will allow you to put together scripts that will automate tasks or produce information for you. The automation capabilities it offers can save much system administration time.

What Is The Syntax Like?

Structure wise, Perl looks a lot like C. Unlike C, Perl is not particularly strict about variable declaration - you can get away with not declaring anything. Obviously, the implications of this need to be accounted for, but for beginners who just wish to get on with some scripting or for people who want to throw together a quick script to automate a task, this can be seen as an advantage.

An Example Perl Script

This is an example of a Perl CGI script.

  1. !/usr/bin/perl
  1. Print HTTP header (\n is newline character)
print "Content-type: text/html\n\n";
  1. Print start of HTML page.
print "<html>\n<body>\n";
  1. Store Hello World in a the string message (\n denotes a new line).
my $message = "Hello World";
  1. Print hello world ten times.
for (1..10) { print $message; }
  1. Print end of HTML page.
print "</body>\n</html>\n";


What Do I Need To Get Started?

Perl scripts can be written in a text editor of your choice. Windows Notepad will be fine, as will VI or Emacs under Linux/UNIX. The SciTE editor has a very pleasant way to write, print readably (with color syntax highlighting) and execute Perl code, in Linux like in Windows: http://www.scintilla.org/SciTEDownload.html. You will then need a copy of the Perl interpreter, or access to a computer which has a copy of the Perl interpreter installed on it. You can obtain Perl freely from any of the following two locations:-

Common Perl Problems

When you upload Perl scripts from a Windows system to a UNIX/Linux system for example, you must do so in ASCII mode. Various operating systems use different characters to denote the end of the line, and if you upload using binary mode in an FTP client the required conversions will not be done.

Are There Any Perl Tools I Can Buy?

You can buy a whole range of Perl development tools from ActiveState. You can also see our Perl downloads section.

What Does Programmers Heaven Offer Me?

Visit the Perl section of the site to see articles on Perl as well as source code, developer tools and links to many sites, including tutorials pitched at many different levels. If you need assistance, why not post your question on our friendly and lively Perl message board.

Further Reading

Amazon.com offers quite a few books on Basic for you to read. A few that may interest you are:

There are also quite a few tutorials available on the internet. Here are a few of them:

last edited (December 23, 2003) by gkalele, Number of views: 18628, Current Rev: 7 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.