Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Get the next character from th ...Output a formatted list to a f ... (Berikutnya)
Input and output functions

Output a list to a filehandle

Daftar Isi

  • print FILEHANDLE LIST

  • print FILEHANDLE
  • print LIST
  • print

    Prints a string or a list of strings. Returns true if successful.FILEHANDLE may be a scalar variable containing the name of or a referenceto the filehandle, thus introducing one level of indirection. (NOTE: IfFILEHANDLE is a variable and the next token is a term, it may bemisinterpreted as an operator unless you interpose a + or putparentheses around the arguments.) If FILEHANDLE is omitted, prints to thelast selected (see select) output handle. If LIST is omitted, prints$_ to the currently selected output handle. To use FILEHANDLE alone toprint the content of $_ to it, you must use a real filehandle likeFH, not an indirect one like $fh. To set the default output handleto something other than STDOUT, use the select operation.

    The current value of $, (if any) is printed between each LIST item. Thecurrent value of $\ (if any) is printed after the entire LIST has beenprinted. Because print takes a LIST, anything in the LIST is evaluated inlist context, including any subroutines whose return lists you pass toprint. Be careful not to follow the print keyword with a leftparenthesis unless you want the corresponding right parenthesis toterminate the arguments to the print; put parentheses around all arguments(or interpose a +, but that doesn't look as good).

    If you're storing handles in an array or hash, or in general wheneveryou're using any expression more complex than a bareword handle or a plain,unsubscripted scalar variable to retrieve it, you will have to use a blockreturning the filehandle value instead, in which case the LIST may not beomitted:

    1. print { $files[$i] } "stuff\n";
    2. print { $OK ? STDOUT : STDERR } "stuff\n";

    Printing to a closed pipe or socket will generate a SIGPIPE signal. Seeperlipc for more on signal handling.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Get the next character from th ...Output a formatted list to a f ... (Berikutnya)