[06:28]$ perldoc -f printf printf FILEHANDLE FORMAT, LIST printf FORMAT, LIST Equivalent to "print FILEHANDLE sprintf(FORMAT, LIST)", except that "$\" (the output record separator) is not appended. The first argument of the list will be interpreted as the "printf" format. See "sprintf" for an explanation of the format argument. If "use locale" is in effect, and POSIX::setlocale() has been called, the character used for the decimal separator in formatted floating point numbers is affected by the LC_NUMERIC locale. See perllocale and POSIX. Don’t fall into the trap of using a "printf" when a simple "print" would do. The "print" is more efficient and less error prone. [06:28]$ perldoc -f sprintf sprintf FORMAT, LIST Returns a string formatted by the usual "printf" conventions of the C library function "sprintf". See below for more details and see sprintf(3) or printf(3) on your system for an explanation of the general principles. For example: # Format number with up to 8 leading zeroes $result = sprintf("%08d", $number); <<>> (minimum) width Arguments are usually formatted to be only as wide as required to display the given value. You can override the width by putting a number here, or get the width from the next argument (with "*") or from a specified argument (with e.g. "*2$"): printf '<%s>', "a"; # prints "" printf '<%6s>', "a"; # prints "< a>" printf '<%*s>', 6, "a"; # prints "< a>" printf '<%*2$s>', "a", 6; # prints "< a>" printf '<%2s>', "long"; # prints "" (does not truncate) If a field width obtained through "*" is negative, it has the same effect as the "−" flag: left-justification.