My quest for perl enlightenment has once again brought me to the Monastery seeking wisdom.
I'm searching for a way to prevent pushing duplicate information into an array... here's an example:
I'm reading a book looking for three words on the same line... say "perl", "monks", and "rule".
I come across the line "I think Perl Monks Rule". So I use the regular expression below to push that entire line into an array for later use:
On the next page of the book, I run across the same line "I think Perl Monks rule",my @Book = (); my @MatchFound = (); foreach (@Book) if ( $_ =~ /\bPerl\b/i && /\bMonks\b/i && /\bRule\b/i ) { push @MatchFound, $_; }
How do I scan the array @MatchFound prior to pushing information to it, to determine if that information is already there?
Or, would it be better to wait until I finish the book, then delete all duplicate lines from @MatchFound (which I have no idea how to do either)?
I know there has to be a term for this type of search... something really abstract like unique array identifier or something. Any ideas?
In reply to Preventing duplicate info from being pushed into an array by neo1491
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |