in reply to Comparing two file in Arrays

In unix two files can be compared in a quick and dirty manner with the comm program. In perl, you probably want to read perldoc -q intersection

Replies are listed 'Best First'.
Re: Re: Comparing two file in Arrays
by MrMadScience (Acolyte) on Jan 02, 2004 at 18:00 UTC
    true. comm is also a good way to do that. Looping through the text file gives the added advantage of being able to discriminately direct the text based on matches, which would otherwise need multiple incantations of comm. Thanks for pointing me to the readme, I think those methods ought to do it for me.

      Algorithm::HowSimilar is probably the fastest solution but only because it uses the excellent Algorithm::Diff module.

      use Algorithm::HowSimilar 'compare'; my ( $av_similarity, $sim_ary1_to_ary2, $sim_ary2_to_ary1, $ref_ary_matches, $ref_ary_in_ary1_but_not_ary2, $ref_ary_in_ary2_but_not_ary1 ) = compare( \@ary1, \@ary2 );

      cheers

      tachyon