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";