Last Updated: February 25, 2016
·
607
· yko

Find Duplicate Code in Perl

SIZE=5120 perl -MCode::DRY \
 -e 'Code::DRY::scan_directories(-$ENV{SIZE}, undef, undef, undef, @ARGV)' \
 lib/

The command does impressive job on finding 'Cut-and-Paste' duplicates and does it fast even on huge codebases.

SIZE variable defines a minimum number of bytes to be considered as duplicate.

The command requires Code::DRY module to be preinstalled.

CP_reporter script from the same distribution provides better reporting interface, but accepts just one dir or a glob.

The module by Heiko "hexcoder" Eißfeldt borrows some ideas from Ovid's implementation and benefits from use of various algorithms and XS performance gains.