open(EXEC, '-|', 'ps', '-deaf | ', 'grep', 'httpd |', 'grep', '-v', 'grep |', 'wc', '-l') or die "Can't exec: $!\n"; # Now read the output just like a file while(my $line = ) { chomp $line; print "$line\n"; } close(EXEC); #### my $input = `ps -deaf | grep httpd | grep -v grep | wc -l`; my $input2 = qx/ps -deaf | grep httpd | grep -v grep | wc -l/; # Same thing