in reply to compare array with file
#! /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 |