Programming Perl

Programming PerlSearch this book
Previous: 3.2.110 printChapter 3
Functions
Next: 3.2.112 push
 

3.2.111 printf

printf FILEHANDLE FORMAT LIST
printf FORMAT LIST

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) function, except that the * field width specifier is not supported. The function is equivalent to:

print FILEHANDLE sprintf LIST

See print and sprintf. The description of sprintf includes the list of acceptable specifications for the format string.

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.


Previous: 3.2.110 printProgramming PerlNext: 3.2.112 push
3.2.110 printBook Index3.2.112 push