Perl Mini-FAQ (Frequently Asked Questions, FAQ)

    People often ask me how I taught Perl - what books I read, what sites I visited, and so on. Many people think that Perl has a complex syntax, and therefore they don’t want or are afraid to learn it. In this FAQ, I would like to share my opinion on the Perl language.

    I heard that Perl is an outdated language and nobody writes it now. Is it so?
    No not like this. Perl is used by system administrators (or simply advanced users) to automate routine work. Perl is used to create websites. Also, ordinary applications are created on it, like in any other programming language.

    Regarding the age of the language - Perl was created in 1986 and since then has been actively developing and changing. Perl currently supports modular and object-oriented programming, regular expressions, etc. - In general, keeps up to date.

    Announcements about the vacancy of a Perl programmer appear with great frequency, while the level of wages, as a rule, is significantly higher than that of programmers in C or Java. However, by the time you read these lines, the situation could have changed, so it’s best to conduct your own research in this direction by visiting, for example, rabota.ru.

    Why is Perl good?
    I would highlight the following advantages of Perl over other programming languages:
    • Programs written in Perl (as with any other scripting language) work equally well under different operating systems.
    • Often, that in another programming language (for example, PHP) takes ten lines of code can be written in Perl in one line.
    • If you are faced with a task, take a look at CPAN. Most likely, someone has already decided it. You just have to download the module and read the documentation for it.


    I heard that Perl syntax is indescribably complex. Is it so?
    Perl syntax is very similar to Java or PHP syntax. The same loops, the same conditional statements, and braces. Perl gained a reputation for a language with complex syntax for its operators, which, as already noted, allow writing shorter code. Let's say you can declare an array of words like this:

    my @arr = ("aaa", "bbb", "ccc");

    or in a simpler way - without commas or quotation marks:

    my @arr = qw/aaa bbb ccc/;

    If you are interested in specific examples in which the Perl code is shorter than any PHP, I allow myself to send you to my blog, and more precisely - to write Interesting examples in Perl . Pay particular attention to the grep and sort operators; consider how much code the similar PHP code would take.

    Where to start learning Perl?
    Personally, I studied with examples. In general, I think this method is the simplest and most understandable. You can easily find them on Google or in my blog already mentioned - in it I often post scripts with comments.

    Nevertheless, I can recommend some good books - We Learn Perl and Perl: Learn More, by Schwartz R. and Phoenix T. Recently these books have been republished, so you will find the easiest and most up-to-date information in them about programming in Perl. I strongly do not recommend taking any other books, as the ones written in them often have long lost their relevance (if the book, say, 2006, remember that Perl is actively developing) or it has 1000 pages written about nothing.

    If you have any questions regarding Perl programming, you can ask for advice in the programming forums (for example, vingrad.ru) or in the ru_perl community.

    I do not want to install UNIX just for the sake of this your Perl!
    And don’t - Perl is ported to Windows. The corresponding project is called ActivePerl. Just download and install ActivePerl from http://www.activestate.com/activeperl/ and enjoy your health. No cracks and keygens need to be searched - the program is free.

    Everything is fine and wonderful. But what about a fly in the ointment?
    Yes, perhaps it is, and not even one.

    Firstly, the so-called “water mattress” law works in any language. In short, it means that the language can be either easy to learn, but the programs on it will consist of a large number of lines (as is the case with PHP), or difficult to learn, but allowing you to write less code (this is just our case).

    Secondly, Perl is not suitable for all tasks. If you are required to write a program that should work quickly (graphical editor, 3D game), Perl will not suit you. Like any other scripting language. Similarly, I would not write Perl drivers.

    Thirdly, although Perl is not difficult to learn in my opinion, it, this very study, takes longer than in the case of another language. For comparison, I mastered PHP in just a couple of nights - variables, loops, classes - there is nothing to know. You can start writing in Perl in the same period of time, but to understand it well, I personally took several months.

    A minus for the hatred of PHP do not want?
    PHP has its advantages, many of which stem from the simplicity of its syntax. Simple syntax means easy to learn. Easy to learn, it means more community.

    Do not underestimate PHP, because thanks to it, such powerful CMS as Drupal and Joomla appeared. I do not know similar Perl projects, except for the WordPress analogue - Movable Type. The latter, by the way, is very popular abroad.

    Update: here I wrote a small post about the basics of programming in Perl, maybe someone will come in handy: http://eax.me/perl-basics/

    Also popular now: