use strict; if (my @matches = /(f.o)(b.r)(b.z)/) { print "Match # $_ is $matches[$_-1]\n" for 1..@matches; }