sprintf function assigns the formatted string to a variable.
#sprintf and printf use the same conversion tables. $string = sprintf("The name is: %10s\nThe number is: %8.2f\n","Ellie", 33); print "$string";