Update: The example below is much better than using system(), please use it as a reference instead. And ++ to robartes :)
Look up system(), it will give you the output or the return value of 'ps' and or 'grep'. Personaly, I would recomend using system for the 'ps' and then using perl to grep through the output to fine what you want.
"Nothing is sure but death and taxes" I say combine the two and its death to all taxes!