in reply to compare array with file

You can use this..
#! /bin/perl -w use strict; my @a = qw ( server1 server2 server3 server5 ); my @b=(); my @c=(); open(FILE,"file") or die "$!\n"; @b=<FILE>; close FILE; chomp(@b); print "a list is @a\n"; print "b list is @b\n"; foreach my $server (@b) { if( ! grep(/$server/,@a)) { push(@c,$server); } } print "c list is @c\n";

Replies are listed 'Best First'.
Re^2: compare array with file
by Divakar (Sexton) on Apr 25, 2012 at 10:45 UTC
    the output would be:
    a list is server1 server2 server3 server5 b list is server2 server5 server7 server8 c list is server7 server8