my @match; while( ) { m[^foo ((?:m \d+ )+)] and @match = split '(?<=\d) (?=m)', $1; print "@match"; }