http://www.perlmonks.org?node_id=408382


in reply to Re: Matching against list of patterns
in thread Matching against list of patterns

To get the matched pattern matched text you can simply do:
my $pattern = join '|', map "($_)", @patterns; ... if ($line =~ /($pattern)/i) { print "matched $1\n"; }
But be carefull if you want to get another matched text in this line. Somewhat it eats up all $1,$2,$3. Use $+ to get the last matched text of the line.

Schuk

Edit: Sorry HV I should learn to read more carefully.