grep doesn't do what you think it does. For a
start you're assigning the return value to a scalar, but it
returns a list.
I think that what you want is something like this:
my @in = qw(bga cbga test);
my @out;
my @test = qw(bga);
foreach my $test (@test) {
push @out, grep { /$test/ } @in;
}
But I'm slightly worried by your phrase "exact pattern
match". Perhaps what you really want is:
my @in = qw(bga cbga test);
my @out;
my @test = qw(bga);
foreach my $test (@test) {
push @out, grep { $_ eq $test } @in;
}
--
<http://www.dave.org.uk>
"The first rule of Perl club is you don't talk about
Perl club."
|