Text::Diff just uses Algorithm::Diff under the covers but returns the differences as text (usually written to STDOUT, I'd guess). Array::Diff is a subroutine of only about a dozen lines using Algorithm::Diff. So just use Algorithm::Diff.
Algorithm::Diff only works on arrays. It actually inserts each line of one of the files into a hash. So, if you've got a huge file, it needs a pretty big hash. The nature of the algorithm nearly requires things be done this way. But 10MB isn't so huge so I doubt you'll have a problem with running out of memory. Though, the number of lines per file might be large enough that the Perl implementation of the 'diff' algorithm (longest common subsequence) might be too slow for your purposes (I have it on my to-do list to make integration with the XS implementation of this algorithm, Algorithm::LCS, supported by Algorithm::Diff so that it uses it if you have it installed).
Your node also prompted me to look again at ways to reduce the amount of memory required by Algorithm::Diff. I think I see some fairly simple ways to dramatically reduce memory requirements so I'm breaking open the module to start working in a new release to make it support doing things much faster with less memory. Wish me luck. (:
|