perlfaq5: multiple answers affected

[email protected] (_brian_d_foy)
Newsgroups perl.perlfaq.workers,perl.documentation
Message-ID <160920021757599141%[email protected]>
* How do I print to more than one file at once?
     + removed unixist discussion of tee.  Perl has modules to do this now. :)

* How can I read in an entire file all at once?
    + mention File::Slurp


Index: perlfaq5.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq5.pod,v
retrieving revision 1.25
diff -u -d -r1.25 perlfaq5.pod
--- perlfaq5.pod        5 Sep 2002 00:48:40 -0000       1.25
+++ perlfaq5.pod        16 Sep 2002 22:54:17 -0000
@@ -690,26 +690,17 @@
 
     for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }
 
-To connect up to one filehandle to several output filehandles, it's
-easiest to use the tee(1) program if you have it, and let it take care
-of the multiplexing:
-
-    open (FH, "| tee file1 file2 file3");
-
-Or even:
+To connect up to one filehandle to several output filehandles,
+you can use the IO::Tee or Tie::FileHandle::Multiplex modules.
 
-    # make STDOUT go to three files, plus original STDOUT
-    open (STDOUT, "| tee file1 file2 file3") or die "Teeing off: $!\n";
-    print "whatever\n"                       or die "Writing: $!\n";
-    close(STDOUT)                            or die "Closing: $!\n";
+=head2 How can I read in an entire file all at once?
 
-Otherwise you'll have to write your own multiplexing print
-function--or your own tee program--or use Tom Christiansen's,
-at http://www.cpan.org/authors/id/TOMC/scripts/tct.gz , which is
-written in Perl and offers much greater functionality
-than the stock version.
+You can use the File::Slurp module to do it in one step.
 
-=head2 How can I read in an entire file all at once?
+       use File::Slurp;
+
+       $all_of_it = read_file($filename); # entire file in scalar
+    @all_lines = read_file($filename); # one line perl element
 
 The customary Perl approach for processing all the lines in a file is to
 do so one line at a time:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.