Perl is a general-purpose, high-level language. It's syntactically
like C, but semantically I find it like Lisp with richer data types.
Perl was first devised for manipulating text and taking care of
UNIXish systems administration tasks, but it was quickly made a
general-purpose language.
To a great extent, programming in Perl is programming that happens
to be in Perl. This means that if you've never programmed before, you
will have to learn some basic concepts to do with the art of
programming; I happen to think Perl is as good a language as any to
start learning these concepts in. If you already have a programming
background, the challenge is to learn your way around in the situations
where Perl provides shortcuts that didn't exist in the languages you've
learned before. Learning to use regexps is a big part of this.
Here's my plan of how to proceed:
Step 1: Shopping Expedition
Buy these books:
- One of these intro texts:
- Learning Perl -- good all around. Aimed at people with programming backgrounds; may be slow going otherwise.
- Beginning Perl -- should be better for people with no programming background. And it's free online here!
- Elements of Programming with Perl -- an excellent and dense book, this should be good for people with programming backgrounds, but it may also be accessible to people with none.
- Teach Yourself Perl in 24 Hours -- despite its title, this is a decent book. The first half (or so) is a good for-beginners introduction, and much of the rest of the book is a surprisingly careful and thorough no-nonsense explanation of CGI, and all sorts of non-obvious design issues that came up when writing CGIs. People not interested in the general-introduction part should consider getting this book, even if only just for its CGI stuff.
- Programming Perl
- Perl Cookbook
- Mastering Regular Expressions (this might not be necessary if you got Elements of Programming with Perl -- its RE explanation seems very thorough)
- Perl Pocket Reference
- Writing CGI Applications with Perl (possibly unnecessary if you got Teach Yourself Perl in 24 Hours)
- And maybe a specialist book or two, like my little book, Perl & LWP, about getting data off the Web with Perl; or like Brent Michalski's handy dandy book Perl Database Programming, which teaches you basic Perl and SQL for doing database stuff.
If you have any introductory books other than the above,
burn them.
There are plenty of Perl books out there that
are, notionally, geared toward beginners (as the titles often imply,
à la Secret Perl CGI for Simpering Halfwits in 7 Days);
but they are all so badly written (destructively bad code, misleading
explanations) as to be worthless for that, or for any other purpose
other than wrecking your brain.
(Yes, the above-listed books are expensive, and you may be adverse to
spending so much on books, especially while there is such a
significant amount of existing free online documentation for Perl.
However, these books, each in their own way, treats topics with a care
and detail that the online documentation can't go into. In short,
they are worth the money, even considering that it's probably
a lot of money for you.)
Step 2: Get Perl
Look at perl.com
for details on that.
Step 3: Read The Manual
Perl comes with lots of
documentation
that you should learn to peruse online
or via
perldoc
.
Read
perlfunc
every month for the first year you're coding Perl.
Ditto for at least the table of contents of the
Big Perl FAQ.
Step 4: Get Modules
Look at all the neat modules in CPAN,
the Perl archive.
Learn to install ones that interest you, and feel free to look
at their source.
Step 5: Practice
Look at example code in The Perl Cookbook.
Subscribe to
The Perl Journal.
Maybe pick up
Effective Perl
Programming.
If you've any OOP background at all (or not!), you must go pick
up Object-Oriented Perl.
Step 6: Think
If your education has not already included reading a good intro
to programming book (and Knuth does not count), get and read
Algorithms + Data Structures =
Programs (by Niklaus Wirth; Prentice-Hall, 1976).
It's currently
out of print
but used copies are, last I looked, to be had cheaply and easily at
ABEbooks.
Consider how you could do different kinds of design in Perl -- functional,
procedural, OOPy, whatever.
Get and worship Higher-Order Perl and Perl Best Practices.
Seek inspiration in the
demented musings of others.
Step 7: Share
If you write a module you think could be of use to others, put it in CPAN.
If you have an idea, talk about it in EFNet-IRC's
#perl
channel.