in reply to `diff`ing two files (code)

You don't say what you're using the output of diff to do. But I would assume that since you're looking at its stdout rather than merely testing $? that you actually are using the diff output.

You may find my Algorithm::Diff module useful for this, though it is somewhat slower than the diff call. However, it may be easier than parsing diff output, depending on what you need to do, since it uses callbacks. Look at traverse_sequences().

On my system, it takes about 0.010 seconds of CPU time to diff two identical 2000-line files using the diff program, and 0.090 seconds of CPU time to diff the same two files using a Perl diff program that uses Algorithm::Diff. However, there is optimization for the common cases of identical lines at the beginning and ends of arrays. Changing the first and last lines results in 0.230 seconds of CPU time.

Anyway, you may want to give it a try.

update: got my decimal places right.