Re: Tracking which elements from an array have been matched.
- From: Jenda@xxxxxxxxxxx ("Jenda Krynicky")
- Date: Wed, 29 Oct 2008 19:13:50 +0100
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
.
- References:
- Tracking which elements from an array have been matched.
- From: Andrew Taylor
- Re: Tracking which elements from an array have been matched.
- From: "Mr. Shawn H. Corey"
- Tracking which elements from an array have been matched.
- Prev by Date: RE: Tracking which elements from an array have been matched.
- Next by Date: Re: matching elements from array and print the results line by line from log file
- Previous by thread: RE: Tracking which elements from an array have been matched.
- Next by thread: signal processing INT or TERM
- Index(es):