How to Program Perl
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:
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 PerlLook at perl.com
for details on that.
Step 3: Read The ManualPerl 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: PracticeLook 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: ThinkIf 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: ShareIf 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
本文出自 51CTO.COM技术博客#perl channel.
|


ericshang
博客统计信息
热门文章
最新评论
友情链接
