in reply to Re: grep or exists
in thread grep or exists
That way it won't work:
$ perl -MProc::ProcessTable -le 'print for @{Proc::ProcessTable->new-> +table}' Proc::ProcessTable::Process=HASH(0x814cb3c) Proc::ProcessTable::Process=HASH(0x827d44c) Proc::ProcessTable::Process=HASH(0x8276e84) Proc::ProcessTable::Process=HASH(0x827d590) Proc::ProcessTable::Process=HASH(0x8276f74) Proc::ProcessTable::Process=HASH(0x8277890) Proc::ProcessTable::Process=HASH(0x8277a40) Proc::ProcessTable::Process=HASH(0x8277bf0) ...
Your match has to become
$_->pid =~ /^$wanted$/
But even then it would be an abuse of grep and of a pattern match, IMHO. Both slightly suboptimal, for
|
|---|