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

licking9Volts has asked for the wisdom of the Perl Monks concerning the following question:

I have a line in my program that looks for an occurrence of any of three phrases. Here's what I have so far:
if (/\bAPI|APIN|UWI\s*\./) { $myvar = $something; }
Is there a way to know exactly which phrase matched and assign it to variable? Example:
if (/\bAPI|APIN|UWI\s*\./) { somesub($matchedpart); }
or would I have to:
if (/\bAPI|APIN|UWI\s*./) { $matchedpart =~ /\bAPI|APIN|UWI\s*./; somesub($matchedpart); }
I've just started using PERL a couple of weeks now, so any advice would be greatly welcomed.