$ 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 $
The easiest way is to use the `` feature in Perl. This will execute what is inside and return what was printed to stdout:
``
my $pid = 5892; my $var = `top -H -p $pid -n 1 | grep myprocess | wc -l`; print "not = $var\n";
This should do it.