Re: Tracking which elements from an array have been matched.



From: "Mr. Shawn H. Corey" <shawnhcorey@xxxxxxxx>
On Wed, 2008-10-29 at 16:29 +0000, Taylor, Andrew (ASPIRE) wrote:
However, I also need to keep a track of which records in the array
have
been 'found' (so I can later identify any records that haven't).


@contains_id = grep {/$rec_id/} @array;
@not_contains_id = grep { $_ !~ /$rec_id/ } @array;

Or you could use the List::MoreUtils::part():

use List::MoreUtils qw(part);

my ($found, $notfound) = part {!( /a/ )} qw(asd wtdfg wrt wrt cv3rcvb
e4h dfg ae wf sdf sdfga);

print "Found: ", join(',', @$found), "\n";
print "Not Found: ", join(',', @$notfound), "\n";

Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

.