Five Ways to Improve Your Perl Programming
I recently finished writing Mastering Perl, the third in the progression of Perl tutorial books from O'Reilly Media. In Learning Perl, we wanted to show the 80 percent of Perl that most people use all of the time. That's good enough to write short script of around 100 lines or so. Next, in Intermediate Perl, we showed how to write reusable code that you could share with others, as well as how to write more complicated programs. When it came to writing Mastering Perl, I considered all of the things that were usually missing from the Perl applications I saw in code reviews. What were Perl programmers missing?
I thought about the life cycle of a typical Perl program. You write a quick hack on Friday afternoon to get something done and then leave for the weekend having accomplished your job, leaving the world a better place. Next Monday, you mention it to Adele, a colleague, and she wants to use it too, so you send her a copy. Another programmer, Bob, wants to use it too, but needs it to work a bit differently. He's a Java guy and doesn't know that much Perl. The change isn't that bad, so you make the modification and send it to him. In the meantime, Adele made her own modifications and passed it on to Charlie.
Pretty soon, your Friday afternoon hack has become mission critical software--how'd that ever happen? Besides your regular work, you're now supporting this script in all of its forms. Dave, the sysadmin, uses find and discovers 17 similar versions of your program--and that's just on one machine.
Now, instead of getting your own work done, you are helping everyone else get his or her work done. What seemed to be a timesaver for your immediate problem is now sucking away your time. I've been in a couple of situations like this when I was a beginning Perler, and along the way I've picked up some things to avoid these situations. You don't have to start every program with the five features I'll show, but once you start using a program for more than just a quick hack, these tips can save you a lot of time supporting your Perl application. Next to the headings, I've provided the corresponding chapter number from Mastering Perl.
597 views
Post new comment