The two ways I understand your question:
First, you want to known what elements from @pcov match with at least one pattern from @realassert.
Second, you want to know what elements from @pcov match with all patterns from @realassert
my @pcov = ('foobar','bilbao','bobo'); my @realassert = map {quotemeta} ('foo','ba'); my $re_one = join '|',@realassert; #print $re_one; my @result_one = grep { /$re_one/ } @pcov; print "one: @result_one\n"; my @result_all = grep { my $item = $_; ! grep { $item !~ /$_/ } @realassert; } @pcov; print "all: @result_all\n"; __END__ one: foobar bilbao all: foobar
edit: You could also look at http://perldoc.perl.org/perlop.html#Smartmatch-Operator
edit2: typo
In reply to Re: Comparing 1 array that matches in 2nd array
by brx
in thread Comparing 1 array that matches in 2nd array
by hongping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |