in reply to Comparing two arrays...
I understand using grep can hinder performance but for your purposes it would work well:
foreach my $service (@ServiceCheckList) { if (grep($service, @ServicesOnMachine)) { print "$service matches\n"; } }
Oops! I didn't spend enough time examining the output. Lame! thanks for pointing it out. This would be better:
foreach my $service (@ServiceCheckList) { if (grep(/^$service$/, @ServicesOnMachine)) { print "$service matches\n"; } }
I'm learning a lot on PerlMonks! Thanks!!!
Dawn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Comparing two arrays...
by LanX (Saint) on Apr 20, 2011 at 21:24 UTC | |
by wallisds (Beadle) on Apr 21, 2011 at 13:32 UTC | |
by LanX (Saint) on Apr 21, 2011 at 13:47 UTC | |
by wallisds (Beadle) on Apr 21, 2011 at 14:05 UTC | |
Re^2: Comparing two arrays...
by Marshall (Canon) on Apr 20, 2011 at 22:20 UTC |
In Section
Seekers of Perl Wisdom