szabgab has asked for the wisdom of the Perl Monks concerning the following question:

I just got a new client that has a bunch of Perl scripts in three almost identical copies.

The story is that they used to have set of scripts dealing with one kind of input. When they started to receive a slightly different set of input - from another source - they copied the scripts and slightly modified some of them to cope with the new input. Then this happened again so now they have 3 sets of almost identical code.

Naturally no unit tests are around.

In addition some of the subroutines were also copied among the files of the original set so I have some duplication there too.

Luckily all of the use strict and warnings and almost no globals so the code is not bad at all.

What would be the best approach to deal with this?

I thought it would be nice to track down the identically named subroutines in the codebase and then recognize if the subroutines are the same or nearly the same, showing the diff between the subroutines.

For extra bonus it would be nice if I could easily unite two almost identical scripts into a module and a scrip. (and what if I have 3 copies...).

So this is a real issue I have now - or rather I had as I manually worked through it in the past 2 days but actually this could be a nice tool and a nice plugin to an IDE.

So let me also add my promotional link here to the Vertical Metre of Beer 3 - The Padre Plugin Contest! I'd be glad to see people starting to write a plugin that can help us handle such a situation.