$test = "xTx\nxxTxxT"; $rx = 'x...T'; @matches = $test =~ /$rx/sg; printf "match #%i:\n%s\n",++$i,$_ for @matches;