in reply to Re: Perl Analyzer?
in thread Perl Analyzer?

Those are exactly the kind of subroutines that would be nice to find and refactor so that
$pencolor
is passed in rather than hardcoded. Paper and highlighter? I asked the question because I don't want to waste time doing that. I feel that 'copy and paste' sytle code leads to code bloat and very, very fragile code.

Replies are listed 'Best First'.
Re^3: Perl Analyzer?
by swampyankee (Parson) on Aug 17, 2006 at 03:27 UTC

    Ideally, you're right: code like that should be refactored unless there's a good reason not to do so (like a requirement to maintain subroutine interfaces, as it was in the pencolor case I mentioned. The code was actually in Fortran-66, and I detest ENTRY statements).

    It would, however, be quite difficult to have a program determine that two subs are doing the same thing, using different code, like one calculating factorials recursively and another doing so with a loop.

    emc

    Experience is a hard teacher because she gives the test first, the lesson afterwards.

    Vernon Sanders Law
      It would, however, be quite difficult to have a program determine that two subs are doing the same thing, using different code, like one calculating factorials recursively and another doing so with a loop.

      So difficult as to be impossible in the general case - since it reduces to the halting problem.