This function uses FORMAT to return a formatted string based on the values in LIST. Essentially identical to printf, but the formatted string is returned instead of being printed.
Following is the simple syntax for this function −
sprintf FORMAT, LIST
This function returns SCALAR, a formatted text string.
Following is the example code showing its basic usage −
#!/usr/bin/perl -w $text = sprintf("%0d \n", 9); print "Formated string $text\n";
When above code is executed, it produces the following result −
Formated string 9