Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl for a Python programmer

Tags:

python

perl

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 Perlish (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?
like image 274
fortran Avatar asked Mar 25 '10 13:03

fortran


People also ask

Is Perl worth learning in 2022?

It is one of the oldest programming languages, but it is still one of the top-paying technologies. One might think that Perl is dead already, and there is no point in learning Perl, but if you have some Perl experience, you will still be in demand. Therefore, this programming language is worth learning in 2022.

Which is easy Perl or Python?

Perl code is not very simple as compared to code written in Python. Python code is simpler and easier to understand. Perl has an impressive support of libraries and so can handle Operations at OS level using built-in functions. Python needs the support of third-party libraries to handle such operations.

Can Python replace Perl?

Python was never intended to replace Perl. Perl was designed to extract stuff from text files. Python was designed as a scripting language for system programming.

Which is better Python or Perl?

Python takes a huge advantage over Perl when it comes to code readability. Python's code is a lot clearer to understand than that of Perl even when reading code after years. With indentation representing the block of code, and proper structuring, Python's code is a lot cleaner.


2 Answers

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.

like image 143
ghostdog74 Avatar answered Oct 27 '22 02:10

ghostdog74


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.

like image 30
daotoad Avatar answered Oct 27 '22 01:10

daotoad