in reply to regex to return matched value from array

your code is not very fast, as you search for $term twice. The following code does what you want :

#!/usr/bin/perl use strict; use warnings; my @myTerms = ( 'foo bar', 'blah' ); my $term = "foo"; my ($match) = ( grep /\Q$term\E/, @myTerms ); print "$term does match with $match\n" if ($match);

Kind regards

--
zejames