Name
sprintf
Synopsis
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:
%m.nxin which m and
n are optional sizes with
interpretation that depends on the type of field, and
xis one of the following:
Code | Meaning |
|---|---|
| Percent sign |
| Character |
| Decimal integer |
| Exponential format floating-point number |
| Exponential format floating-point number with uppercase E |
| Fixed-point format floating-point number |
| Floating-point number, in either exponential or fixed decimal notation |
| Like |
| Long decimal integer |
| Long octal integer |
| Long unsigned decimal integer |
| Long hexadecimal integer |
| Octal integer |
| String |
| Unsigned decimal integer |
| Hexadecimal integer |
| Hexadecimal integer with uppercase letters |
| The 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
nis 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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access