in reply to How to find the difference between two text files using a hash array
Consider using List::Compare to compare the two arrays. Below is an example of its use. The results show items that appear only in the left list contained by @array1:
use strict; use warnings; use List::Compare; my @array1 = split /\n/, <<END1; /home filer1232:/vol/home1 /mystuff filer1233:/vol/project /data filer1234:/vol/example_data /software filer1255:/vol/my_software /tools filer1235:/vol/my_tools /docs filer146:/vol/my_documents END1 my @array2 = split /\n/, <<END2; /home filer1232:/vol/home1 /mystuff filer1233:/vol/project /data filer1234:/vol/example_data /tools filer1235:/vol/my_tools END2 my $lc = List::Compare->new( \@array1, \@array2 ); my @Lonly = $lc->get_unique; print "$_\n" for @Lonly;
Output:
/docs filer146:/vol/my_documents /software filer1255:/vol/my_software
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to find the difference between two text files using a hash array
by NewLondonPerl1 (Acolyte) on Jan 20, 2013 at 21:39 UTC | |
|
Re^2: How to find the difference between two text files using a hash array
by NewLondonPerl1 (Acolyte) on Jan 20, 2013 at 21:48 UTC | |
by Kenosis (Priest) on Jan 21, 2013 at 01:28 UTC | |
by Anonymous Monk on Jan 21, 2013 at 07:32 UTC |