in reply to Retrieve "ps -ef" strings using regex

You are taking the full result of ps in a single string, checking if there is a match and then printing the entire string. This results in printing the entire result if there is at least a match.

What you want to do is to split the string in an array of lines and then check & print each of them.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

Replies are listed 'Best First'.
Re^2: Retrieve "ps -ef" strings using regex
by linuxer (Curate) on Aug 27, 2008 at 19:49 UTC

    instead of reading the result into a scalar and split it afterwards, you could assign the result of the backticks to an array.

    my @lines = qx{ command | grep what };