you read all the lines from a file handle (
$syscmd) and take the third column of each and put this in
@list. You then want to see which elements of a second list are NOT in
@list.
Here's how i'd do it: just remove from
%pro all of the elements in @list.
# the values here don't matter, all we really
# care about is the existence of the keys
my %pro = map { $_, 1 }
qw[CMD /bin/sh rds SysExec /oasis/bin/sysmenu
/oasis/bin/TS_TextSrvcs];
# get the third column from every line of $syscmd
my @list = map { (split " ")[3] } <$syscmd>;
# remove the keys of %pro in @list
delete @pro{@list};
# print the error message
foreach my $not_found (keys %pro) {
print "Didn't find $not_found in output of system cmd.\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.