or download this
E:\>perl -le "print 'foo baz'=~/(foo|foo|foo)\s(?{print qq(Got '$1')})
+ba[r]/ ? qq(Matches '$1') : 'No match!'"
Got 'foo'
...
E:\>perl -le "print 'foo baz'=~/(foo|foo|foo)\s(?{print qq(Got '$1')})
+bar/ ? qq(Matches '$1') : 'No match!'"
No match!