use strict; use warnings; my $x = "Mmm...donut, thought Homer"; if (my @matches = $x =~ /^(Mmm|Yech)\.\.\.(donut|peas)/) { unshift @matches => undef; foreach my $expr (1..$#-) { print "Match $expr: '$matches[$expr]' at position ($-[$expr],$+[$expr])\n"; } }