Полезная информация

Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: splitChapter 5
Function Reference
Next: Reference: sqrt


sprintf format, list

Returns a string formatted by the printf conventions. The format string contains text with embedded field specifiers into which the elements of list are substituted, one per field. Field specifiers are roughly of the form:

where the m and n are optional sizes whose interpretation depends on the type of field, and x is one of the following:

%Percent sign
dDecimal integer
eExponential format floating-point number
EExponential format floating-point number with uppercase E
fFixed-point format floating-point number
gFloating-point number, in either exponential or fixed decimal notation
GLike g with uppercase E (if applicable)
ldLong decimal integer
loLong octal integer
luLong unsigned decimal integer
lxLong hexadecimal integer
oOctal integer
uUnsigned decimal integer
xHexadecimal integer
XHexadecimal integer with uppercase letters
pThe Perl value's address in hexadecimal

Special value that stores the number of characters output so far into the next variable in the parameter list.

m is typically the minimum length of the field (negative for left-justified), and n is precision for exponential formats and the maximum length for other formats. Padding is typically done with spaces for strings and zeroes for numbers. The * character as a length specifier is not supported.

Previous: Reference: splitPerl in a NutshellNext: Reference: sqrt
Reference: splitBook IndexReference: sqrt