What is Perl ?
General background info about Perl:
Perl today is an very versatile tool being used for a large
number of different tasks including system administration, web
programming, database programming, general software development,
text-manipulation, socket-programming etc. People not only write
simple scripts but also develop very large programs in Perl and this
is feasible with the object oriented features that Perl currently
supports.
One of the major strengths is the portability, virtually all
operating systems support Perl with the major ones being Unix and
Windows. Most courses I have taught have used Windows (XP/2000/NT)
as the platform and it has worked very well indeed. Clearly today
there are no good scripting languages bundled with Windows and those
available (VisualBasic etc) are unable to address the typical system
administration tasks that your are facing on Windows. Perl among other
tasks is addressing this niche quite well: a number of NT specific
extensions ("modules") have been developed that lets you administer
users, printers, registry, events etc on Windows. On the other hand, Unix
was always strong with shell-scripts but the traditional shell
scripting approach is far from ideal when you have to write something
that is slightly more complex (or something that cannot be allowed to
end up as "spaghetti-code").
The biggest reason for Perl's recent popularity is Web-programming:
O'Reilly has estimated (in 1998) that ~90% of dynamic Web-pages are generated
with Perl. Perhaps that figure is too optimistic but is very
evident that Perl is a popular language for backend
Web-application programming. Accordingly, lots of useful modules have been
developed that make CGI/Web-programming very easy.
Often closely related to Web-programming is Database-access: eg you can
write a Perl Web-application that runs on Unix talking to Oracle and
move this to NT talking to Informix without changing a single line of
code. In addition the abstraction level is very high, one example I use
in class: a C-SQL application is 400+ lines of code, in Perl it is
9 lines of code.
Web-client programming is also an interesting application: you might
want to regularly download stuff from the Net (such as a mailing list
archive), check your WWW-links, mirror Web-sites etc. Perl has
high-level modules for this purpose as well, eg it takes a 2 line
program to write an application in Perl that download a given url and
writes it to a file. I use several Perl Web-clients in my own environment
that are essential for how I use the Internet more effectively.
Perl 5 that came out in 1994 introduced the concept of modules:
extensions to Perl that embed significant functionality in a
well-tested piece of code that can be reused over and over again
Currently about 10000 modules are available that help you in virtually any kind of
task you can imagine. And as Perl itself, they are free and come with
the source code. Some examples: Database, Web (client/server),
Network-client (FTP, Telnet, NNTP etc etc), System-Admin (eg Windows
specific extensions), GUI-programming (portable graphical user
interfaces between Windows and X/Motif), Security etc etc.
To summarize, in my opinion the main advantages with Perl are in
addition to the points mentioned above:
- easy to get started, also targeted to people who are not professional programmers
- very fast development cycle
- lots of Perl developers (1-2 million)
- cross platform support (Unix, Windows (XP/2000/NT/W98/W95), Mac, OS2, DOS, VMS, MVS,
MPE, Amiga etc)
- very strong in text-manipulation, also supports binary data
(unlike shell scripts)
- source code debugger (in contrast to traditional shell
scripts), profilers and other development tools, even
free GUI builders
- supports Object Oriented development and advanced data
structures. In fact all the recent significant modules use
OO techniques in order to facilitate better reusability.
- access to object-code written in C/C++, used by most major
modules such as databases, X/Motif and Windows extensions etc.
- support: the Internet provides an excellent support channel
with active newsgroups (~1500 messages / week). Commercial
support also available.
- security: Perl contains some unique facilities to write secure
applications, especially useful in CGI/Web applications
- a large number of high level modules are available
- it is FREE. This applies both to Perl and all the 3800
modules on the so called CPAN (Comprehensive Perl Archive
Network)
- it is FUN ! Perl is the most enjoyable environment I have
worked with so far and an environment (unlike C) where you
essentially force the computer to think like a human and not
the human to think like a computer... Think about a simple
thing like copying an array in C: you have to express this
to the computer in a "HOW"-fashion (allocate memory, move
the pointer, copy one element, move the pointer, copy the
next element...) instead of saying the "WHAT" you want to do
as you can do in Perl: @x = @y (@ is symbol for the
array). Perl will take care of all the nasty details for
you: allocate memory, copy the elements etc.