开发者

Perl for a Python programmer

开发者 https://www.devze.com 2022-12-24 20:09 出处:网络
I know Python (and a bunch of other languages) and I think it might be nice to learn Perl, even if it seems that most of the people is doing it the other way around.

I know Python (and a bunch of other languages) and I think it might be nice to learn Perl, even if it seems that most of the people is doing it the other way around.

My main concern is not about the language itself (I think that part is always easy), but about learning the 开发者_如何学PythonPerlish (as contrasted with Pythonic) way of doing things; because I don't think it'll be worth the effort if I end up programming Python in Perl.

So my questions are basically two:

  • Are there many problems/application areas where it's actually more convenient to use Perl rather than Python?
  • If the first question is positive, where can I found a good place to get started and learn best practices that is not oriented to beginners?


One area where Perl is more "convenient" is using it for one liners. Python can be used to produced one liners, but often its "clunky" (or ugly). Note that Perl is renowned for its "terseness" or "short and concise", often at the expense of readability. So coming from Python, you have to learn to get used to it.

Another area is Perl's vast number of modules in CPAN. The equivalent of that is Pypi but its modules are not as many as CPAN.

that said, both do similar things and both have their own merits.

As for your second question, you can look at Perl documentation. I find it very useful. Especially also read the Perl FAQ. They are the best resource for myself if I want to learn about Perl.


For best practices, check out Perl Best Practices by Damian Conway. Not all of the recommended practices make sense, but most of them do.

The Perl::Critic module also helps with best practices.

Also, check out the Modern Perl Books blog.

If you have questions, Perlmonks is the best web forum to get help. There are a large number of very knowledgeable, friendly people who can, and will, answer your questions and discuss the merits of different approaches.


  • Have a look at Moose. Its a state of the art OO framework akin to CLOS and what will be available in Perl6. It introduces the new(ish) concepts of roles and will steer you close to Aspect-oriented programming.

  • Functional Programming. Checkout the Higher-Order Perl book by Mark Jason Dominus (PDF download available from this site).


Impatient Perl

One of my favorite books for people who want to learn it and then get stuff done is Impatient Perl by Greg London, a free netbook available from perl.org. If you're a programmer, know scripting, know the concepts behind dynamic languages, and just want to know how perl does it, this is a great starting resource.


I think Learning Perl from O'Reilly Media is a pretty good way to get started with Perl, even if you are already proficient in Python.

Especialy if you want to get to know the one-liner stuff (and this is what Perl is REALLY good at)


Effective Perl Programming is mostly for people who know the basics of Perl's syntax but need to learn the idioms. We also cover similar stuff in our Effective Perler blog :)

0

精彩评论

暂无评论...
验证码 换一张
取 消