Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Tool for diff'ing/anaylyzing two branches of same Perl code?by stevieb (Canon) |
on Nov 18, 2015 at 17:57 UTC ( [id://1148045]=note: print w/replies, xml ) | Need Help?? |
Hey LanX, Recently I updated one of my modules to use PPI, so this was fresh in my memory. This won't get you all the way, but it's a sane way to remove all POD and comment elements, as well as providing you an array of the sub names in the order they are currently listed in the file you're working on.
Hope this helps! Update: added code to catch the original order of subs in the file. Update2: I monkeyed around with one of my own modules Devel::Examine::Subs (v1.56+) that does subroutine maintenance, and with some trickery (as a PoC), wrote a script that strips POD and comments, gets the order of the sub names, removes all subs from each file, and inserts them back in (starting at the first line where the first sub used to start in each file) in the order taken from the first argument. Just pass the script the two files, starting with the one who's sub order you want to keep.
I know others have provided solutions already, but I'm curious to see how far this actually gets you. It assumes both files have the same subroutines, and the data is written to the same files passed in, with a ".new" extension. Update: if you've read this far, you see what I'm trying to do. I'm going to take the CPAN namespace Devel::Examine::File so I can extend what I've already done, and make it officially file-based. The want that OP desired is something I've wanted to expand into anyways, and it will alleviate some of the hacks I have in the current module that it just shouldn't be doing.
In Section
Seekers of Perl Wisdom
|
|