sprintf#

Format a string POSIX-style, identical to built-in sprintf.

תקציר#

use POSIX qw(sprintf);
my $line = sprintf("%-10s %6.2f", $name, $price);

מה מוחזר#

A single scalar holding the formatted string. Conversion specifiers, flags, width, precision, and length modifiers are whatever your built-in sprintf supports.

מקרי קצה#

  • Called with no arguments: croaks with Usage: POSIX::sprintf(pattern, args...).

  • Too few arguments for the format: unfilled specifiers expand to the empty string, matching the core sprintf.

הבדלים מן ה-upstream#

Fully compatible with upstream POSIX.