[This article was adapted from the Perl 5 manual pages. -JP]
Other articles in this chapter were actually written for the previous
version, Perl 4, but they apply to Perl 5 as well. Perl 5 is
nearly a complete rewrite of Perl 4. Most Perl 4 scripts will work
under Perl 5. Perl 5 has these new benefits (and more):
Many usability enhancements
: It is now possible to write much
more readable Perl code (even within regular expressions). Error
messages are more informative; the optional warnings will catch many
of the mistakes a novice might make.
: Perl variables may now be declared within a
lexical scope, like "auto" variables in C.
Arbitrarily nested data structures
: Any scalar value, including
any array element, may now contain a reference to any other variable
Modularity and reusability
: The Perl library is now defined in
terms of modules that can be easily shared among various packages. A
package may choose to import all or a portion of a module's published
interface. Pragmas (that is, compiler directives) are defined and
used by the same mechanism.
: A Perl package can function as a
class. Dynamic multiple inheritance and virtual methods are supported
in a straightforward manner and with very little new syntax.
Filehandles may now be treated as objects.
Embeddable and extensible
: Perl may now be embedded easily in
your C or C++ application, and can either call or be called by your
routines through a documented interface. The XS preprocessor
is provided to make it easy to glue your C or C++ routines into Perl.
Dynamic loading of modules is supported.
: A major new module is the POSIX
module, which provides access to all available POSIX routines
and definitions, via object classes where appropriate.
Package constructors and destructors
: The new BEGIN and
END blocks provide means to capture control as a package is
being compiled, and after the program exits. They work just like
's BEGIN and END when you use the
Multiple simultaneous DBM implementations
: A Perl program
may now access DBM, NDBM, SDBM, GDBM, and
Berkeley DB database files from the same script simultaneously.
Regular expression enhancements
: If you thought Perl 4 regular
expressions were rich and full of incredible features, wait until you
see Perl 5!