I did test it (see code below). It seemed to work for me but I see from some of the comments that it can be used in a much better way.
#!/usr/bin/perl -w
use strict;
my @ServicesOnMachine = qw(NetworkManager acpid anacron atd auditd aut
+ofs avahi-daemon avahi-dnsconfd bluetooth capi conman cpuspeed crond
+cups dnsmasq dund firstboot gpm haldaemon hidd hplip httpd ip6tables
+iptables irda irqbalance iscsi iscsid isdn kudzu lvm2-monitor mcstran
+s mdmonitor mdmpd messagebus multipathd netconsole netfs netplugd net
+work nfs nfslock nscd ntpd oddjobd pand pcscd portmap psacct rawdevic
+es rdisc readahead_early readahead_later restorecond rpcgssd rpcidmap
+d rpcsvcgssd saslauthd sendmail smartd sshd svnserve syslog tcsd vbox
+add vboxadd-service vboxadd-x11 vncserver wdaemon winbind wpa_supplic
+ant xfs ypbind yum-updatesd);
my @ServiceCheckList = ("spray", "echo", "daytime", "discard", "charge
+n", "ttdb", "ypbind", "ypserv", "yppasswdd", "ypxfrd", "tooltalk", "r
+statd", "comsat", "talk", "uucp", "finger", "netstat", "systat", "rus
+ers", "walld", "rexd", "rje", "netbios", "lpd", "http", "gopher", "tc
+pmux", "news", "nntp", "snmp", "mail", "smtp", "pop2", "pop3", "sendm
+ail", "httpd");
foreach my $service (@ServiceCheckList) {
if (grep($service, @ServicesOnMachine)) {
print "$service matches\n";
}
}
Correction
foreach my $service (@ServiceCheckList) {
if (grep(/^$service$/, @ServicesOnMachine)) {
print "$service matches\n";
}
}
Thanks!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.