austin43 has asked for the wisdom of the Perl Monks concerning the following question:
which contains:@ServicesOnMachine = `/sbin/chkconfig --list | awk '{print \$1}'`;
My 2nd array is:NetworkManager acpid anacron atd auditd autofs 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 mcstrans mdmonitor mdmpd messagebus multipathd netconsole netfs netplugd network nfs nfslock nscd ntpd oddjobd pand pcscd portmap psacct rawdevices rdisc readahead_early readahead_later restorecond rpcgssd rpcidmapd rpcsvcgssd saslauthd sendmail smartd sshd svnserve syslog tcsd vboxadd vboxadd-service vboxadd-x11 vncserver wdaemon winbind wpa_supplicant xfs ypbind yum-updatesd
I want to make it so if any values from the 1st and 2nd array match up, it will print the output... Probably something like....?@ServiceCheckList = ("spray", "echo", "daytime", "discard", "chargen", + "ttdb", "ypbind", "ypserv", "yppasswdd", "ypxfrd", "tooltalk", "rsta +td", "comsat", "talk", "uucp", "finger", "netstat", "systat", "rusers +", "walld", "rexd", "rje", "netbios", "lpd", "http", "gopher", "tcpmu +x", "news", "nntp", "snmp", "mail", "smtp", "pop2", "pop3", "sendmail +", "httpd");
Obviously this isn't it but I need something to print only matching values. Thanks in advance! :)foreach (@ServiceCheckList eq @ServicesOnMachine) { print $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing two arrays...
by choroba (Cardinal) on Apr 19, 2011 at 21:34 UTC | |
|
Re: Comparing two arrays...
by jwkrahn (Abbot) on Apr 19, 2011 at 21:42 UTC | |
|
Re: Comparing two arrays...
by LanX (Saint) on Apr 19, 2011 at 21:36 UTC | |
|
Re: Comparing two arrays...
by wallisds (Beadle) on Apr 20, 2011 at 17:36 UTC | |
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 | |
by Marshall (Canon) on Apr 20, 2011 at 22:20 UTC | |
|
Re: Comparing two arrays...
by Marshall (Canon) on Apr 20, 2011 at 21:45 UTC |