Perl has a lot of slogans. Probably the most popular is “There’s More than One Way To Do It” (TMTOWTDI). However, some ways of doing things are frowned upon in the Perl community. In this article, I present four heresies for those pariahs who dare to go against the establishment.
I have two reasons for disliking the Perl Orthodoxy. First, it discourages the idea that if you know enough Perl to get your job done, then you know enough Perl. Second, programming is an artistic as well as a technical discipline, so just as “wrong notes” can make a good piece of music better, programmers should be free to use these for-bidden constructs if it makes their programs more aesthetically pleasing. However, this comes with a caveat: as with music, if you don’t know why you’re breaking the rules, you probably shouldn’t be.
According to my reading of the 5.004 source, Perl has around sixty optional warnings. If you are a moderately skilled Perl programmer, you will see only one or two of them on a regular basis.
I rarely use
-w. For whatever reason, the kind of mistakes I make are not ones that it catches. The most frequent appearance of
-w warnings in my programs is due to DBI queries that return rows with empty columns. Since there’s no way to predict in advance which columns will be empty, I get a slew of
Use of uninitialized value at line… messages.
-w generates its warnings based on conditions that change at runtime, it makes the behavior ...