Chapter 10. Modifying and Jury-Rigging Modules
Although there are over 10,000 distributions in CPAN, sometimes it doesn’t have exactly what I need. Sometimes a module has a bug or needs a new feature. I have several options for fixing things, whether or not the module’s author accepts my changes. The trick is to leave the module source the same but still fix the problem.
Choosing the Right Solution
I can do several things to fix a module, and no solution is the right answer for every situation. I like to go with the solutions that mean the least amount of work for me and the most benefit for the Perl community, although those aren’t always compatible. For the rest of this section, I won’t give you a straight answer. All I can do is point out some of the issues involved so you can figure out what’s best for your situation.
Sending Patches to the Author
The least amount of work in most cases is to fix anything I need and send a patch to the author so that he can incorporate them in the next release of the module. There’s even a bug tracker for every CPAN module[39]and the module author automatically gets an email notifying him about the issue.
When I’ve made my fix I get the diffs,
which is just the parts of the file that have changed. The diff command creates
the patch:
$ diff -u original_file updated_file > original_file.diff
The patch shows which changes someone needs to make to the original version to get my new version:
% diff -u -d ISBN.pm.dist ISBN.pm --- ISBN.pm.dist 2007-02-05 00:26:27.000000000 ...