#!usr/bin/perl use warnings; use strict; my $x = "Mmm...donut, thought... Homer...Yech...peas"; my @matches = $x =~ /(Mmm|Yech)\.\.\.(donut|peas)/g; print "number of matches is: ".@matches."\n"; print "matches are: @matches\n"; print "\n"; $x = "MmmABCdonut, thought... HomerABXYechABYpeas"; my @moreMatches = $x =~ /(?:Mmm|Yech)(...)(?:donut|peas)/g; print "moreMatches number: ".@moreMatches,"\n"; print "@moreMatches\n"; __END__ prints: number of matches is: 4 matches are: Mmm donut Yech peas moreMatches number: 2 ABC ABY