printf

printfFILEHANDLEFORMAT,LISTprintfFORMAT,LISTprintfFILEHANDLEprintfLISTprintf
This function prints a formatted string to
FILEHANDLE or, if omitted, the currently
selected output filehandle, initially STDOUT. The first item in the
LIST must be a string that says how to format
the rest of the items. This is similar to the C library’s
printf(3) and fprintf(3)
functions. The function is equivalent to:
FILEHANDLEsprintfFORMAT,LIST
except that $\ ($OUTPUT_RECORD_SEPARATOR) is not
appended.
See Chapter 26 for how formats are interpreted. We’d duplicate all that here, but this book is already an ecological disaster.
An exception is raised only if an invalid reference type is used
as the FILEHANDLE argument.
If you omit both the FORMAT and the
LIST, $_
is used—but, in that case, you should have been using print. Don’t fall into the trap of using a
printf when a simple print would do. The print function is more efficient and less
error prone.
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