September 2017
Beginner
402 pages
9h 52m
English
The printf method prints the values in the given format. It is mostly identical to the printf function from the C and C++ standard library. The first argument of this method is a string describing the format, and the rest of the arguments are the values that will be substituted instead of the directives, starting with the % character in the format string.
In many cases, formatting can be achieved by string interpolation instead. For example, the following two lines produce the same output:
my $temperature = 25.6;
printf("Temperature is %g °C\n", $temperature);
say "Temperature is $temperature °C";
In the following tables, the main formatting directives are listed.
Read now
Unlock full access