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



On Wed, 2008-10-29 at 16:29 +0000, Taylor, Andrew (ASPIRE) wrote:
I have an array of records. I need to search this array for a
particular record (or records) based on a record id.

This is simple enough (e.g. using the grep function)

@found = grep {/$rec_id/} @array;

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;


--
Just my 0.00000002 million dollars worth,
Shawn

Linux is obsolete.
-- Andrew Tanenbaum

.



Relevant Pages

  • Re: Switching two characters
    ... use warnings; ... Just my 0.00000002 million dollars worth, ... Linux is obsolete. ...
    (perl.beginners)
  • Re: Bug in Perl [OT]
    ... Just my 0.00000002 million dollars worth, ... Shawn, I just ask out of curiosity, your signature said: ... "Linux is obsolete." ...
    (perl.beginners)
  • Re: Switching two characters
    ... your one-liner above? ... Just my 0.00000002 million dollars worth, ... Linux is obsolete. ...
    (perl.beginners)
  • RE: variable in perl
    ... Answers can be found in `perldoc perlvar`. ... Just my 0.00000002 million dollars worth, ... Linux is obsolete. ...
    (perl.beginners)
  • Re: Hash sort order
    ... gives the warning. ... Just my 0.00000002 million dollars worth, ... Linux is obsolete. ...
    (perl.beginners)