kevin liu wrote:
Hello everyone:
Hello,
When I am using a pattern match to find my wanted process, things like
this:
*********************************************************************************************
ps -ef | grep hald-runner
root 5006 5005 0 Mar04 ? 00:00:00 hald-runner
kevin 8261 3896 0 16:53 pts/10 00:00:00 grep hald-runner
*********************************************************************************************
but I don't want the second process item, so I write this code to
filter:
@array = qx{ps -ef | grep hald-runner};
You can use a pattern that will match 'hald-runner' but not 'grep
hald-runner' by enclosing at least one of the characters in a character
class:
my @array = qx{ps -ef | grep hald-r[u]nner};
The pattern 'hald-r[u]nner' will match the string 'hald-runner' but not
the string 'hald-r[u]nner'.
But it is better to use Perl's grep function than the external grep program:
my @array = grep /hald-runner/, qx{ps -ef};
chomp @array;
foreach ( @array ) {
if (/grep hald-runner/) {
next;
}
}
Here my confusion comes: What the grep here will mean??
Here "grep" is just a plain text or a verb which can help to grep
contents??
In the if conditional 'grep' is just a text string.
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/