Skip to Content
Mastering Perl
book

Mastering Perl

by brian d foy
July 2007
Beginner
342 pages
8h 30m
English
O'Reilly Media, Inc.
Content preview from Mastering Perl

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Perl

Beginning Perl

Curtis Ovid Poe
Perl & LWP

Perl & LWP

Sean M. Burke
Perl by Example

Perl by Example

Ellie Quigley
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe

Publisher Resources

ISBN: 9780596527242Supplemental ContentErrata Page