juo has asked for the wisdom of the Perl Monks concerning the following question:
How can I look for an exact pattern match. I would like to interrogate a pattern and remove exact matches out of the array which occur in another array. If I use (grep s/$temp/ /ig,@new_array) then it will remove all matches instead of exact matches. See example below. Any clues ?
use strict; my @array = qw (bga); my @new_array = qw (bga cbga test); print "@array\n"; foreach my $temp(@array) { chomp($temp); my $tester = grep s/$temp/ /ig,@new_array; } print "@new_array\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to look for exact pattern match
by davorg (Chancellor) on Oct 30, 2001 at 15:22 UTC | |
by juo (Curate) on Oct 30, 2001 at 15:47 UTC | |
by davorg (Chancellor) on Oct 30, 2001 at 16:00 UTC | |
by clintp (Curate) on Oct 30, 2001 at 18:03 UTC | |
by Fletch (Bishop) on Oct 30, 2001 at 16:56 UTC | |
|
Re: How to look for exact pattern match
by arhuman (Vicar) on Oct 30, 2001 at 16:04 UTC |