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:
Is there a way to know exactly which phrase matched and assign it to variable? Example:if (/\bAPI|APIN|UWI\s*\./) { $myvar = $something; }
or would I have to:if (/\bAPI|APIN|UWI\s*\./) { somesub($matchedpart); }
I've just started using PERL a couple of weeks now, so any advice would be greatly welcomed.if (/\bAPI|APIN|UWI\s*./) { $matchedpart =~ /\bAPI|APIN|UWI\s*./; somesub($matchedpart); }
Back to
Seekers of Perl Wisdom