Day 1: Tutorials: Advanced Perl Programming
Tom Christiansen has been using Perl since its first versions and has been
teaching perl since 1989. In other words, it's a subject he knows a little
bit about .
Besides, on top of obviously being a knowledgeable speaker, Tom is a fun
speaker just like Larry (Wall, although it's also true of
The interesting thing is that he wrote his slides in troff macros, which
get parsed by a few programs of his and end up in postscript, but then I also
found out that the perl books were written in perldoc, and troff where perldoc
wasn't enough. A book in perldoc, pfheww...
Here are a few random bits from his tutorial (I hope I didn't mess anything up):
- %Foo:: is the hash of variables in package Foo
- INIT is called automatically just like BEGIN in a package, but it's just
before running the package, not at the time it is compiled. To have the
whole file in scope, INIT can be put at the end of the file.
- use sigtrap lets you trap an exception like a signal so that END
- do $file will run a file located in the @INC search path
while the ugly `cat $file` will not use the @INC path,
requires a cat binary and puts the file in the local scope
- use Fcntl () works like require Fcntl except that it
happens at compile time, and use also allows for function
signatures, if there are any, to be checked for consistency.
- require $file works like do $file, but each loaded file
is stored in the %INC path so that it's never loaded twice (no
if defined file_h hack, like in C header files)
- file.pl is a perl library, so that extension shouldn't be used for perl
- A package name shouldn't be all lower case because those names are reserved
- Carp is nice for error reporting. carp is like warn,
and croak is like die, but they report an error message
from the caller perspective. You also have confess and
cluck which give a full stack backtrace.
- ref $var returns the type of variable that $var is a
- Perl tends to overallocate memory grossly (next power of two) which can be
an issue for multidimensional arrays, so you should be prepared to have up
to 10 times more memory than needed (maybe more). There are also CPAN
modules that are designed to handle multidimensional data structures more
efficiently (those are usually written in C).
- Tom read some perl book where ISA (from @ISA) stood for Industry
Another well known Perl hacker, Chip, was in the audience and helped answer
a few questions at the end.
Link to Home Page
99/08/09 (22:20): Version 1.0