Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
RFC: perl sub diff between two filesby bliako (Monsignor) |
on Mar 26, 2018 at 12:24 UTC ( [id://1211734]=perlmeditation: print w/replies, xml ) | Need Help?? |
Fellow Monks,
Recently, I was in need to compare two versions of the same perl module containing many subs. I was interested to see the difference between the contents of subs with the same name. This happened because I forked the same code in two different machines and made changes in the modules in both machines. For this purpose I wrote the following basic script which I place here for public use but also for comments from the monastic community. The simple script makes use of two excellent modules, namely PPI and Text::WordDiff. PPI parses perl code and is capable of extracting subs and their contents. Text::WordDiff outlines (and color-codes) the differences between two blocks of text (the contents of identically-named subs in two files). Unix's diff is a fine tool in general, but code has a few idiosyngracies which make diffing sometimes impractical. For example when same-content subs have different order in their respective files. That said, I wanted a quick tool to check my two versions of the perl module, find enhancements in either file I made and produce a final version. Here is the script:
bliako
Back to
Meditations
|
|