@numbers = (4, 5, 6); # not necessarly consecutive $str = 'test number X'; my $fmt=$str; $fmt=~s/X//; my @newArray=map { "$fmt$_" } @numbers; print join "\n",@newArray;