in reply to Re: Why Perl Docs examples do not use strict and warnings often
in thread Why Perl Docs examples do not use strict and warnings often

For years, I claimed I was not a developer. For the same years, I used primarily Perl for the same reason you do.

Your observation is valid and appreciated. I too find it conflicting when I see statements like "Always do X and Y", but then the examples don't follow suit. I suppose some of us take for granted the things we've ingrained our neural pathways with.

One of the fortunate, yet unfortunate long-standing design aspects of Perl was and has been to keep backward compatibility at the forefront of importance. For this reason, strict isn't enabled by default. It's up to us to remember to do so. When a newcomer comes along and doesn't see that in all examples, I can understand it being something easy to forget. To people like me who have been coding in Perl for a couple of decades, it's like remembering to put butter on my toast.

I think that all examples in Perl documentation may be better served by having the strict (and possibly warnings) lines, if every document doesn't make that clear in the intro explicitly. Unfortunately, I have not the time to make those changes to all documentation, so I'm not going to say it "should" be done.

The best we can do as a compromise as far as I see, is continue informing people the importance of such mechanisms, and reminding them why they exist (and in some cases, why they aren't set by default). It's new coders like you who notice these important conflicts and acknowledge them that allows us all to renew conversation on the matter, so other new coders can see, understand and learn.

Safe programming can be done without use strict; and use warnings;, but there's not a single file of Perl code I've ever written, deployed or published that don't have those two lines at the top.

Good question.