my %ServiceCheckList; @ServiceCheckList{ qw/ spray echo daytime discard chargen ttdb ypbind ypserv yppasswdd ypxfrd tooltalk rstatd comsat talk uucp finger netstat systat rusers walld rexd rje netbios lpd http gopher tcpmux news nntp snmp mail smtp pop2 pop3 sendmail httpd / } = (); open my $PIPE, '-|', '/sbin/chkconfig', '--list' or die "Cannot open pipe from '/sbin/chkconfig' because: $!"; while ( <$PIPE> ) { chomp; print "$_\n" if exists $ServiceCheckList{ $_ }; } close $PIPE or warn $! ? "Error closing '/sbin/chkconfig' pipe: $!" : "Exit status $? from '/sbin/chkconfig'";