Don't ask to ask, just ask | |
PerlMonks |
Six way diff? (Solved. Low-tech rules!)by BrowserUk (Patriarch) |
on Apr 24, 2015 at 22:39 UTC ( [id://1124618]=perlquestion: print w/replies, xml ) | Need Help?? |
BrowserUk has asked for the wisdom of the Perl Monks concerning the following question: I have six chunks of 52 lines of very similar code that I need to isolate all the differences in. I've been tackling it by eye, and have it mostly working, but there remains some small difference that I'm not seeing; and I'm going bug-eyed for looking. Anyone any thoughts how to do a six-way diff? Everything below is update.I settled for a low tech solution that worked surprisingly well. First, I put the six chunks of code into separate files. Then I wrote the following simple Perl script that loaded the lines of those files in to an AoAs: all the line 1s in to one array, all line 2s in to another; and so on; and then printed them to standard out:
What I got after normalising the files and lines -- which was surprisingly quick by referencing the output -- was stuff that looked like this:
I piped that into a file, wrapped it into a subroutine and eliminated the duplicates, then went through the sets of lines with differences and parameterised them one at a time. The result is: <Reveal this spoiler or all in this thread>
Where first six lines are the call sites and the rest the fully parameterised function. And the best bit: IT WORKS! The names need work, but that's true for all the names in the library. And a job for tomorrow. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Back to
Seekers of Perl Wisdom
|
|