Rather than using a system call to ps and grep, you could do the whole thing in perl using Proc::ProcessTable.
BazB
In reply to Re: Re: Getting PIDs by BazB in thread Getting PID's by konda_sk