Question

I recently joined a Perl project and I need to start being productive with the codebase fairly quickly. However, I'm finding that I'm getting stuck because I don't know where I need to change or how all the parts of the code fit together.

What are your tips and tools for becoming familiar with a Perl codebase that you have no experience with?

(Note: I realize that there's already a similar question. I'm wondering if there's any Perl-specific strategies.)

Was it helpful?

Solution

First, if the previous maintainers were doing their job well, you should have an extensive test suite and perldoc documentation for each module and script in the codebase. If so, read through the perldoc, and read through the tests. The perldoc should give you an overview of what things do, and the test suite will give you examples of the code being used in context.

Depending on the author, the internal comments may be useful in understanding the intention of the code, so looking through the actual source my provide insights into algorithms, bugs, and intended use as well.

If you don't have any of these, proceed as you would for any badly-maintained codebase: start small, writing programs that try to use the code, and use Test::More and the like to start turning these into a test suite.

In the first case, you may find it to be very simple, in the second, very hard. Peter Scott's Perl Medic can be very useful in assisting you in turning such a codebase into something usable and useful if you're stuck with the second case, and Mike Thomsen's recommendation of Effective Perl Programming is also a good one.

OTHER TIPS

I work on Melody which is written primarily in Perl. It's a rather large code base, and I've found the process of learning the Melody code base is identical to any Java system I've worked on.

It really comes down to just working with it, googling when you see behavior you've never seen before and experimentation.

This book is a great reference for picking up Perl in a serious way. It's not very dense and it will teach you a lot about proper Perl development.

Besides the "similar question", http://perldoc.perl.org/ and an empty test.pl file is a good starting point!

I would like to see a real answer here. The only thing I have is more questions (you don't have to provide answers here, just ask yourself):

Goal

  1. What is the goal of the project, what it is supposed to do?
  2. Who knows the workflow?

Environment

  1. Can you set up the project in a clean test environment?
  2. Does it use a versioning system?
  3. Where are the entry points (i.e. executable files)?
  4. Does it rely on external programs?
  5. Does it require additional system tweaks (i.e. cron scripts)?

Perl code

  1. Is your project using strict and warnings everywhere?
  2. Which CPAN modules are used?
  3. Are there any frameworks used (Moose, Catalyst, probably some ORM, ...)?
  4. Are there any perldocs in the project's modules?
  5. Are there any tests (notably t/*.t)?

I usually start with working on some simple bug report or a simple feature I want to add. While working on code I write comments for code and commit them. Writing tests also helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top