print

FILEHANDLELISTprintFILEHANDLEprintLISTprint
This function prints a string or a comma-separated list of
strings. If set, the contents of the $\ ($OUTPUT_RECORD_SEPARATOR) variable will be implicitly printed at the end of the list. The
function returns true if successful, false otherwise. The current value
of $, (if any) is printed between
each LIST item. The current value of $\ (if any) is printed after the entire
LIST has been printed.
To use FILEHANDLE alone to print the
content of $_ to it, you must use a
real filehandle like FH, not an
indirect one like $fh.
FILEHANDLE may be a scalar variable name
(unsubscripted), in which case the variable contains either the name of
the actual filehandle or a reference to a filehandle object of some
sort. As with any other indirect object,
FILEHANDLE may also be a block that returns
such a value:
print { $OK ? "STDOUT" : "STDERR" } "stuff\n";
print { $iohandle[$i] } "stuff\n";If FILEHANDLE is a variable and the
next token is a term, it may be misinterpreted as an operator unless you
interpose a + or put parentheses
around the arguments. For example:
print $a – 2; # prints $a – 2 to default filehandle (usually STDOUT) print $a (– ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access