@l = repeated('this dog a round', 'this dog a pound', 1, 3); @l = repeated('this dog a round', 'this dog a pound', 1, 4); #### sub repeated { ($s,$_,$m,$n)=@_;my@p;for$i($m..$n){$s=~$1&&push@p,$&while/\b(?=((\w+\b ?){$i}))/g}@p }