printf function prints a formatted string.
Format Specifiers
Conversion Definition
%b Unsigned binary integer
%c Character
%d, i Decimal number
%e Floating point number in scientific notation
%E Floating point number in scientific notation using capital E
%f, %F Floating point number
%g Floating point number using either e or f conversion, whichever takes the least space
%G Floating point number using either e or f conversion, whichever takes the least space
%ld, %D Long decimal number
%lu, %U Long unsigned decimal number
%lo, %O Long octal number
%p Pointer (hexadecimal)
%s String
%u Unsigned decimal number
%x Hexadecimal number
%X Hexadecimal number using capital X
%lx Long hexidecimal number
%% Print a literal percent sign
Related examples in the same category
1. | Prints a welcome statement with escape character | | |
2. | Prints a welcome statement with several escape characters | | |
3. | You can pass a list of items to print, where you separate the list items with commas: | | |
4. | The print command prints out the text you provide it | | |
5. | Output two values in one print statement | | |
6. | print "Hello!\n"; | | |
7. | Using comma in a print statement | | |
8. | Mix the string the integer calculation in a print statement | | |
9. | Output the result of multiply with string | | |
10. | Output the result of division with string | | |
11. | Print only care about the first parenthesis | | |
12. | Put all into a parenthesis for print statement | | |
13. | Get the Power | | |
14. | Printing Output | | |
15. | Using Perl Built-in Functions | | |
16. | print function prints a string or a list of comma-separated words to the Perl filehandle STDOUT. | | |
17. | If the strings are not quoted, the filehandle STDOUT must be specified, or | | |
18. | The filehandle STDOUT must be specified if strings are not quoted. | | |
19. | Printing Numeric Literals | | |
20. | Printing String Literals | | |
21. | surrounding FINIS with single quotes | | |
22. | x 4 says that the text within the here document will be printed four times. | | |
23. | If terminator is in backquotes, will execute OS commands | | |
24. | The HTML tags are embedded in the here document to avoid using multiple print statements | | |
25. | Format text output with HTML tags | | |
26. | print 16 % 3; | | |
27. | print 2048 >> 3; | | |
28. | print 24 & 15; | | |
29. | print sqrt 4; | | |
30. | print -e STDIN; #Does STDIN exist? | | |
31. | print -t STDIN; #Is it tied to a terminal? | | |
32. | print -z STDIN; #Does it have zero size? | | |
33. | print $_ >= 0 ? $_ : -$_ | | |
34. | print $_ < 10 ? $_ : "${\((a .. f)[$_ - 10])}\n"; | | |
35. | print 1, 2, 3, 4, sort 9, 8, 7, 6, 5; | | |
36. | Print out here document | | |
37. | Syntax for the print Function | | |
38. | printf Flag Modifiers | | |
39. | Using the print Function | | |