What are some common mistakes made by Perl developers, and how can we avoid them?
Please look in to the list before posting a new answer.
Please justify your answer as well, if applicable, and give examples.
What are some common mistakes made by Perl developers, and how can we avoid them?
Please look in to the list before posting a new answer.
Please justify your answer as well, if applicable, and give examples.
The most common mistake I see, is that people do not view it as a programming language - they view it as a "scripting" language, a switch flicks in their brain, and they stop using all the techniques that they would use for C/C++ etc (this also happens for shells like bash etc.).
So treat perl as a programming language and code accordingly - always use use strict
, -w
, functions, encapsulation, etc. etc. etc.
The biggest mistake I find from new Perl programmers is thinking that they can write useful programs without learning anything about the language. It's very easy to get started with Perl since you don't need to learn an IDE or fancy tools, so people make their initial programs to print a line of text then keep guessing at program elements as they go further. They end up wasting a lot of time trying to solve a problem. You don't have to use my book Learning Perl, but you should spend some time with at least one tutorial. A good tutorial can save you literally hundreds of hours of work in the short term.
After that, developers should learn how to use the documentation, and even struggle with it a bit before asking questions. That's how you learn to use the documentation. If you only ever ask questions on places like Stackoverflow, you only ever get very targeted answers for your specific problem. The more you try to use the docs, the better you get at it. I even wrote a tongue-in-cheek Perl documenetation documentation page to help you get started.
Lastly, as with all languages, you can avoid many problems with the judicious use of proper algorithms and data structures. I find, however, that poor developers have so much trouble just dealing with syntax (in any language), that they never get to the higher level where they can think critically about the structure of their program.
You should always start you program with these lines, until you understand what they do.
use strict;
use warnings;
Coding first, thinking second. It's real easy to do that with a dynamic language.