in reply to sentence generation

This is a perfect use of sprintf. Just use a %d in the sentence template whenever you want a number substituted:
my $template = "The lucky numbers of the day are %d, %d, %d, %d, %d +" . "and don't forget to play again next week."; my @numbers = qw/ 10 435 239 42 999 /; ## substitute numbers for %d in the template my $output = sprintf($template, @numbers); print "$output\n";
Your code can vary its behavior depending on how many numbers are in the sentence template: simply count the number of occurences of %d in the template, and splice or slice off that many elements from @numbers to use with that template. I'll leave the rest to you. ;)

blokhead