
| Contents |
|||||||||||||||
| [an error occurred while processing this directive] |
2.2.1.1 Printing Numeric Literals
As with string literals, you can also use the which produces the output:#!/usr/bin/perl use strict; use warnings; print 2E-4, ' ', 9.77E-5, " ", 100.00, " ", 10_181_973, ' ', 9.87E9, " ", 86.7E14, "\n"; 0.0002 9.77e-05 100 10181973 9870000000 8.67e+15
First of all, we have done something new here with In this case, we gave a list of arguments that included both string and numeric literals. That is completely acceptable, since Perl can usually tell the difference! The string literals are simply spaces, which we are using to separate our numeric literals on the output. Finally, we put the newline at the end of the output.
Take a close look at the numeric literals that were output. Notice that
Perl has made some formatting changes. For example, as we know, the
|