Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Finding duplicated code in Perl

by diotalevi (Canon)
on Nov 26, 2003 at 14:08 UTC ( #310251=note: print w/ replies, xml ) Need Help??


in reply to Finding duplicated code in Perl

My first thought is to run your code through B::Concise, perhaps use Idealized optrees from B::Concise to simplify the output and then look for subtrees that are equal. From there you are free to do something useful with the filename and line number hints scattered at every ';' node. In fact, you could automate this by writing a script to run B::Concise, find equal trees and then annotate the original code with comments that match.


Comment on Re: Finding duplicated code in Perl
Re: Re: Finding duplicated code in Perl
by shushu (Scribe) on Nov 26, 2003 at 14:29 UTC
    True, but I understand it means the answer to "do you know any existing tool" is "no"..
    From www.onjava.com I got this:
    "CPD could be adapted to work with C, C++, PHP, Ruby, Perl, or any other language for which a tokenizer exists. There could be a runtime toggle to select which language to parse."

    In case I can fit to the existed interface of CPD I won't need to develop a tool of my own.

    I believe what they mean in tokenizer can be some kind of modified B::* module.
    Am I on the right track ?
      They mean something that can parse the language. You could adapt B::Deparse to output something that produces the output requested by CPD. The thing is though... the work I suggested in the previous node is very do-able. That's a relatively short script. I have no need for this and so won't write it but I could see this being a relatively minor thing.
      FWIW, PPI::Tokenizer?

      It's one part of the PPI project thats stable now.

      Or by tokenizer do they mean, "tokenizer written in our language to our interfaces"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://310251]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-12-26 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (167 votes), past polls