Since you want the first match, which should be the only match, use List::Util's first:grep($_->pid == $wanted, @{$p->table} )
use List::Util qw(first); my $match = first {$_->pid == $wanted} @{$p->table};
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to Re^3: grep or exists
by merlyn
in thread grep or exists
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |