Why throw away the results of ps? (What's wrong with using backticks in a void context?)foreach my $pation (@occupation) { `ps -ef|grep -i $pation|grep -v grep|wc -l`; }
If the intention is to count the number of instances of interesting programs from the process list, there is no need to repeat the execution of the ps command.
/prakashmy @programs = qw(netman jobman mailman batchman writer); my @all_procs = `ps -ef`; my %counts; for (@programs) { $counts{$_} = scalar grep {/$_/i} @all_procs; } print "$_ $counts{$_}," for keys %counts; print "\n";
In reply to Re: (jeffa) Re: array newbie...(sigh)
by PrakashK
in thread array newbie...(sigh)
by ddrumguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |