| 300 | | FILEHANDLE may be a scalar variable name, in which case the variable |
| 301 | | contains the name of or a reference to the filehandle, thus introducing |
| 302 | | one level of indirection. (NOTE: If FILEHANDLE is a variable and |
| 303 | | the next token is a term, it may be misinterpreted as an operator |
| 304 | | unless you interpose a C<+> or put parentheses around the arguments.) |
| 305 | | If FILEHANDLE is omitted, prints by default to standard output (or |
| 306 | | to the last selected output channel--see L</select>). If LIST is |
| 307 | | also omitted, prints C<$_> to the currently selected output channel. |
| 308 | | To set the default output channel to something other than STDOUT |
| 309 | | use the select operation. |
| 310 | | |
| 311 | | =begin comment |
| 312 | | |
| 313 | | [ I don't know what's become of $, and $\. -markstos ] |
| 314 | | |
| 315 | | The current value of C<$,> (if any) is |
| 316 | | printed between each LIST item. The current value of C<$\> (if |
| 317 | | any) is printed after the entire LIST has been printed. |
| 318 | | |
| 319 | | =end comment |
| 320 | | |
| 321 | | Because print takes a LIST, anything in the LIST is evaluated in list context, |
| 322 | | and any subroutine that you call will have one or more of its expressions |
| 323 | | evaluated in list context. Also be careful not to follow the print keyword |
| 324 | | with a left parenthesis unless you want the corresponding right parenthesis to |
| 325 | | terminate the arguments to the print--interpose a C<+> or put parentheses |
| 326 | | around all the arguments. |
| 327 | | |
| 328 | | Note that if you're storing FILEHANDLEs in an array, or if you're using |
| 329 | | any other expression more complex than a scalar variable to retrieve it, |
| 330 | | you will have to use a block returning the filehandle value instead: |
| 331 | | |
| 332 | | print { @files[$i] } "stuff\n"; |
| 333 | | print { $OK ?? STDOUT !! STDERR } "stuff\n"; |
| | 305 | FILEHANDLE, if supplied, must be a filehandle object. Indirect objects |
| | 306 | in Perl 6 must always be followed by a colon, and any indirect object |
| | 307 | more complicated than a variable should be put into parentheses. |
| | 308 | |
| | 309 | If FILEHANDLE is omitted, prints to standard output. |
| | 310 | The form with leading dot prints C<$_> to standard output. |
| | 311 | (It is a compiler error to use a bare C<print> without arguments.) |
| | 312 | |
| | 313 | There is are no variables corresponding to Perl 5's C<$,> and |
| | 314 | C<$\> variables. Use C<join> to interpose separators; use filehandle |
| | 315 | properties to change line endings. |