in reply to regex to return matched value from array

use List::Util qw[ first ]; my @terms = ( 'foo bar', 'blah' ); my $term = 'foo'; my $match = first{ /\Q$term/ } @terms; print $match; foo bar

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon