```{index} single: sprintf; POSIX function ``` ```{index} single: POSIX::sprintf; Perl function ``` # sprintf Format a string POSIX-style, identical to built-in `sprintf`. ## Synopsis ```perl use POSIX qw(sprintf); my $line = sprintf("%-10s %6.2f", $name, $price); ``` ## What you get back A single scalar holding the formatted string. Conversion specifiers, flags, width, precision, and length modifiers are whatever your built-in `sprintf` supports. ## Edge cases - 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`. ## Differences from upstream Fully compatible with upstream POSIX.