in reply to How to find the difference between two text files using a hash array

There is a short way to do it, but it's a bit complicated for beginners to understand:
use strict; use warnings; use Data::Dumper; my @config = ( '/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', ); my @mounted = ( '/home filer1232:/vol/home1', '/mystuff filer1233:/vol/project', '/data filer1234:/vol/example_data', '/tools filer1235:/vol/my_tools', ); my %diff; @diff{@config}=(); delete @diff{@mounted}; print Dumper [keys %diff];
output
$VAR1 = [ '/docs filer146:/vol/my_documents', '/software filer1255:/vol/my_software' ];

See also

  • Using hashes for set operations...

  • How do I compute the difference of two arrays? How do I compute the intersection of two arrays?.

    (EDIT:repaired FAQ link)

    Cheers Rolf

  • 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 22:05 UTC
      Thanks alot Rolf. I tried your suggestion and this is working perfectly :-)