Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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!


In reply to Re^3: Comparing two arrays... by wallisds
in thread Comparing two arrays... by austin43

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found