To output a scalar, you can use the print
and printf
built-in
functions. We have already seen examples of the print
command, and
the printf
command is very close to that in C or C++. Here are a few
examples:
use strict; my $str = "Howdy, "; my $name = "Joe.\n"; print $str, $name; # Prints out: Howdy, Joe.<NEWLINE> my $f = 3e-1; printf "%2.3f\n", $f; # Prints out: 0.300<NEWLINE>