in reply to map question

I have this fear I'm answering a homework question, but I can't resist...
@numbers = (4, 5, 6); # not necessarly consecutive $str = 'test number X'; my $fmt=$str; $fmt=~s/X/\%d/; my @newArray=map {sprintf $fmt,$_} @numbers; print join "\n",@newArray;
By modifiying your format string to have "%d" it becomes something that sprintf can handle.

Another alternative would be:

@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;
But that only works because your "X" is at the end of the string.
--
Mike