in reply to What is being matched?
In 5.10+, see also named capture buffers:
>perl -wMstrict -le "my $str = 'The CEO of WidgeCo resigned today.'; ;; $str =~ m{ (?<BIGWIG> chairman | president | ceo ) }xmsi; ;; if (exists $+{BIGWIG}) { print qq{a $+{BIGWIG} was mentioned}; } " a CEO was mentioned
Update: For the position in the string of the match(es), see @- and @+ in perlvar.
|
|---|