Chas. Owens wrote: > On Wed, Feb 18, 2009 at 19:59, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote: >> Chas. Owens wrote: > snip >>> This is not the best way to go about solving this problem (use diff or a >>> module like Text::Diff*), >> If we are going to suggest a module, List::Compare would be more to the >> point IMO. > snip > > No, the lines should not make it out of the files into arrays in the > first case. Reading whole files into arrays is one of the reasons > this code is bad. Well, I see it as a directory comparison problem rather than a general file comparison problem. The reason that at least one of the listings had been saved in a file seems to be that the directory is located on some other server. It's true that reading whole files into arrays often consumes memory unnecessarily, but give it a thought how much memory a complete text file comparison would have consumed. > snip >>> It is important to note that this algorithm only works if you care about >>> unique lines. If you need to know that file1 has 5 lines of "foo" and file2 >>> has 4 lines of "foo", this code will not tell you that. >> Since the files contain file names from directory listings, that cannot be >> applicable to the problem at hand. > snip > > Yes, but it is an important thing to note lest you try to use it for > something else later. Absolutely; this is not a general solution for comparing text files. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.plThread Previous | Thread Next