I'd actually start from the other end, looking for infrequently-occuring-but-nonunique lines. A line which is used in exactly 2 or 3 places is more likely to be part of a block of cut and paste than one used in 100.
That's a great suggestion, I hadn't thought of that yet. Thanks!
I'm well aware of the various refactoring techniques, and I do use both OO and functional approaches where appropriate. Your example is illustrative enough though, although your walk_tree should probably read:
sub walk_tree { my $tree = shift; my $per_node = shift; walk_tree($tree->left); $per_node->($tree->node); walk_tree($tree->right); }
In reply to Re^2: Refactoring tools for copy/paste jobs
by rhesa
in thread Refactoring tools for copy/paste jobs
by rhesa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |