in reply to Re: Refactoring tools for copy/paste jobs
in thread Refactoring tools for copy/paste jobs

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); }

Replies are listed 'Best First'.
Re^3: Refactoring tools for copy/paste jobs
by jbert (Priest) on Oct 09, 2006 at 16:14 UTC
    Thanks for the correction (which I've incorporated into the original node - this reply is partly to record that fact).

    And I'm sorry if I seemed to imply that you might not be aware of such techniques - no offence intended.