Suppose you want to write a program in Perl. (Suppose you have written a program in Perl.) If the thesis behind what I call Modern Perl is correct, you can write that program well or you can write that program poorly. (For supporting arguments for that thesis, see Piers Cawley's A tale of two languages.)
Likely you've seen examples of Poorly Written Perl on the Internet. They serve as the YouTube comments to Nabokov of English language. In other words, the proper response to a reluctant admission that:
Yes, I know that Perl can be written in an object-oriented and readable way.
— Tim Bray, D.P.H.
... or that:
There's also been a push in some applications to rewrite Perl utilities in Bash to enhance portability between platforms. While Perl exists on just about every platform out there, there are vagaries that can cause issues with differing Perl versions, which then leads to portability problems.
— Paul Venezia, Is it still libelous if you end your titles with question marks?
... the proper response is "Why didn't you write your code with maintainability in mind?"
I know, I know. That's not helpful. Here's a quick checklist to help those of you writing Perl (or those of you trying to hire people to write Perl (or those of you trying to hire people to learn to write Perl)) to determine if you're capable of writing Perl well:
- Do you know how to use the Perl documentation
- Do you use CPAN modules?
- Do you use the CPAN distribution layout for organizing your code?
- Have you enabled strictures and warnings? Is the resulting code clean of warnings and errors?
- Are you using the standard Perl testing framework? (Did you write tests at all?)
- Do you have an automated Perl configuration, build, dependency resolution, installation, and distribution mechanism?
- Does your code conform to local Perl layout guidelines?
- Does your code conform to Perl community standards for maintainability and correctness?
- Are you familiar with the local Perl mongers group?
- Are you using a recent version of Perl?
- Are you familiar with writing secure Perl?
- Do you use source control?
- Do you use functions?
- Do you use modules?
- Do you use objects?
- Do you use Moose or another abstraction mechanism from the CPAN?
- Do you document your Perl code?
- Do you use language constructs you don't understand, copied and pasted from elsewhere, smushed together into a hateful melange of barely-working confusion you occasionally tweak just to see what happens, and one afternoon you get sick of it and call it done?
You don't have to answer all of those questions in the correct way to write good and maintainable Perl, but if you answer most of those questions in the wrong way, of course you'll write bad code.
Perl allows people to accomplish their tasks without having to learn much, without having to participate in strange and unfamiliar ceremonies, and without even being much good at programming at all. That's by design, and that's a good thing for very specific circumstances. Yet if you approach programming as if it were merely typing and retyping until something barely working fell out of your typewriter, you're going to make lots of messes, and no language can save you from an unprofessional lack of discipline.
Writing good code requires discipline in any language.