Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find copy/paste (duplicate, clone) code in Perl?

I've searched the Internet for a while now and I have not been able to find any free (or cheap) tools/utilities/modules that can analyze a set of Perl files (modules or scripts) and flag duplicate or cloned or copy/pasted code.

I'm better now, but I used to copy and paste sections of code all over the place. I'd like to clean it up and fix my old code duplication, but a little bit of tool help would be appreciated so I won't have to go through all my old code with a fine tooth comb. Plus, manual recognition of this sort of offense is error prone.

like image 541
Kurt W. Leucht Avatar asked Sep 22 '09 18:09

Kurt W. Leucht


Video Answer


2 Answers

Funny a similar question was posted to SO just a few minutes ago.

Here is a link with some tools you may find useful.

Code Comparison and Plagirism Detection

like image 193
RC. Avatar answered Oct 12 '22 13:10

RC.


What do you mean by duplicate code? Just character exact matches or semantic matches.

There are several tools like http://pmd.sourceforge.net/ that can detect duplicate code by string matches, this tool is for java but the source matching works on plain text.

If you want semantic matching, like

sub A
{return 1;}

to match

sub B
{
    return 1;
}

Then you'll need something else:(

like image 35
chollida Avatar answered Oct 12 '22 12:10

chollida