PERL PRIMER 1.
TOPICS COVERED IN THIS PRIMER:
- About Perl.
- Why Perl.
- Why Not Perl.
Perl is a programming language, It's Object Oriented, simple to learn and very
powerful. Perl stand for: "Practical Extraction and Reporting Language" but others
have come up with many more interesting and colorful names for it. :-)
Perl is "the little language that could" it's designed to be able to do as many tasks
as possible in as little time as possible. As someone once said, "A good perl program
is one that gets the job done before your boss fires you."
(The someone was Larry Wall,
the creator of Perl.)
Perl is an Interpreted language, so you don't have to compile it like you do Java, C, C++
etc. For fast development work, that's a godsend.
There are a ton of reasons why Perl is a great language for use in CGI development and general processing.
Here are but a few of them:
- Learning. Perl has all the same abilities, data constructs and methods of other languages, and its easier to learn then most.
If you understand Perl, you will have far less trouble learning other languages like C, C++, Java, PHP etc then if you were starting
- Interpreted language means less time spent debugging.
- Mod_perl for CGI work means perl can be as fast as compiled languages without the need to manually compile.
- CPAN.org, a massive collection of perl modules that can do almost anything, someone has usually done the work for you.
- Because Perl was not designed to only be a web development language, it can do much much more, image creation, networking via telnet,ssh or ftp (and others)
GUI graphical application work and more.
- Taint mode, this helps you to write secure code by not trusting any data provided by the users until you have tested and declared it safe.
- Online support. Perl has been around since the early 90's, its exceptionally well known and thousands of tutorial and help sites abound on the internet.
- ISP support. Perl runs on nearly anything, it comes standard on the vast majority of unix/linux servers and is available free for windows servers. As a result its the
most commonly supported language on ISP (Internet Service Providers) hosting servers.
- Text processing. Because perls' initial reason for living was text processing, its regular expression engine is exceptionally powerful.
That means advanced text manipulation is easier then ever. (and lets face it, nearly all programming is text manipulation of some sort.
- Database connectivity. Thanks to the DBI module, perl can talk to a great many different databases with the same syntax. That means that you only have to learn one
interface to talk to over a dozen different database servers. That's as opposed to learning each DB's syntax and commands seperately.
- Freebies. Since Perl has been around for ages, there are thousands of scripts on the internet that are free to use and/or modify.
- Cross Platform compatability. A perl script for linux/unix will work just as well in windows and vice versa, and the only exceptions to that rule are those dicticated by the
operating system itself. (for example file paths are different in windows and unix.)
In Short, most people just want to get the job done, and done as quickly and with as little fanfare as possible
and for this, Perl is your friend. Its the lazy programmers language of choice.
WHY NOT PERL.
All languages have areas that they excel in, and others that they don't. Perl is no different.
Technically, you could write anything in Perl, even a complete operating system. but that does not mean you should.
Its a matter of considering your requirements and deciding on the best language to suit them.
Here are some reasons why Perl might not be your best choice:
- Speed. If for example, you were writing a huge word processer like M$ Word or WordPerfect. the sheer size of it would make it extrememly slow to compile at runtime.
For this you would be much better served by a language like C or C++ where the compilation is done before you run it. (compilation is the process by which a human readable program is translated into a binary language that your computer would understand.)
- That's all I can think of right now, undoubtably there are other reasons that in certain circumstances a different language is called for, when I think of some, I'll add them here.
If you want a demo of what Perl can do, look no further then this very site.
The entire content of the tutorials menu is Perl generated
(Perl looks in the tutorial directories on the server, and not only makes a list of links to all the files in them, but it also extracts the summary information from the files themselves and displays that as well.)
Much of the rest of this site is Perl generated also, the "Don time, Franki time" listing in the footer is pure Perl, as is the random donation reason displayed in the footer, the hidden page counter,
the IRC chat client and the Forum. As you can see, Perl is capable of nearly anything, and we have only begun to scratch the surface.
Well, there you go... This will hopefully have helped you decide if Perl is a language you will find of good use. If so, read on, the next primers will cover the basics of perl syntax and layout.
If not, perhaps you should consider PHP, a language designed from the ground up for developing server parsed online documents.