Perl sprintf Function

Advertisements


Description

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.

Syntax

Following is the simple syntax for this function:

sprintf FORMAT, LIST

Return Value

This function returns SCALAR, a formatted text string.

Example

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 produced following result

Formated string 9 


Advertisements
Advertisements