$ cat test.pl my $pid = 5892; my $not = system(\"top -H -p $pid -n 1 | grep myprocess | wc -l\"); print \"not = $not\\n\"; $ perl test.pl 11 not = 0 $
Use backtick for system commands which helps to store their result into Perl variable.
my $pid = 5892; my $not = ``top -H -p $pid -n 1 | grep myprocess | wc -l`; print "not = $not\n";