# Previous version : my $l = " $a! $b"; while($l =~ s/(.*)(( \w+){$m,$n} )(.*!.*\2.*)/ $1 =$4/) { push @r, $2; }; @r