[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
BeginnersGuideToPerl
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
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.
- !/usr/bin/perl
print "Content-type: text/html\n\n";
- Print HTTP header (\n is newline character)
print "<html>\n<body>\n";
- Print start of HTML page.
my $message = "Hello World";
- Store Hello World in a the string message (\n denotes a new line).
for (1..10) { print $message; }
- Print hello world ten times.
print "</body>\n</html>\n";
- Print end of HTML page.
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:- Writing CGI Applications with Perl
- Learning Perl (3rd Edition)
- Sams Teach Yourself Perl in 21 Days (2nd Edition)
- Programming Perl
- CGI Programming 101
- Developer's Daily Articles and Tutorials List
- JWCS.NET Learning Zone Perl Tutorials
- Beginning Perl
- Perl CGI Tutorial
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
