summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-03-22 13:30:38 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-22 13:30:38 +0000
commit8f8f6e09d34f5d0588c3287bc99d33cf16f7fc13 (patch)
tree43611012b4078000d00deed7b305ea90acaa8ace /pod
parentbf8bfa4121b4899a02951de3f1089e6c522c60dc (diff)
downloadperl-8f8f6e09d34f5d0588c3287bc99d33cf16f7fc13.tar.gz
FAQ sync.
p4raw-id: //depot/perl@15415
Diffstat (limited to 'pod')
-rw-r--r--pod/perlfaq3.pod2
-rw-r--r--pod/perlfaq5.pod26
-rw-r--r--pod/perlfaq6.pod2
3 files changed, 12 insertions, 18 deletions
diff --git a/pod/perlfaq3.pod b/pod/perlfaq3.pod
index ff79139be3..0f678f1a37 100644
--- a/pod/perlfaq3.pod
+++ b/pod/perlfaq3.pod
@@ -154,7 +154,7 @@ for indenting, ^D is for undenting, and ^O is for blockdenting--
as it were. A more complete example, with comments, can be found at
http://www.cpan.org/authors/id/TOMC/scripts/toms.exrc.gz
-The a2ps http://www-inf.enst.fr/%7Edemaille/a2ps/black+white.ps.gz does
+The a2ps http://www-inf.enst.fr/%7Edemaille/a2ps/black+white.ps does
lots of things related to generating nicely printed output of
documents, as does enscript at http://people.ssh.fi/mtr/genscript/.
diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod
index 701a757558..e7bcee2a22 100644
--- a/pod/perlfaq5.pod
+++ b/pod/perlfaq5.pod
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq5 - Files and Formats ($Revision: 1.12 $, $Date: 2002/03/11 22:25:25 $)
+perlfaq5 - Files and Formats ($Revision: 1.13 $, $Date: 2002/03/16 15:37:26 $)
=head1 DESCRIPTION
@@ -496,6 +496,7 @@ literals
open FILE, "<", " file "; # filename is " file "
open FILE, ">", ">file"; # filename is ">file"
+
It may be a lot clearer to use sysopen(), though:
@@ -763,21 +764,7 @@ more fun to use the standard DB_File module's $DB_RECNO bindings,
which allow you to tie an array to a file so that accessing an element
the array actually accesses the corresponding line in the file.
-On very rare occasion, you may have an algorithm that demands that
-the entire file be in memory at once as one scalar. The simplest solution
-to that is
-
- $var = `cat $file`;
-
-Being in scalar context, you get the whole thing. In list context,
-you'd get a list of all the lines:
-
- @lines = `cat $file`;
-
-This tiny but expedient solution is neat, clean, and portable to
-all systems on which decent tools have been installed. For those
-who prefer not to use the toolbox, you can of course read the file
-manually, although this makes for more complicated code.
+You can read the entire filehandle contents into a scalar.
{
local(*INPUT, $/);
@@ -790,6 +777,13 @@ close the file at block exit. If the file is already open, just use this:
$var = do { local $/; <INPUT> };
+For ordinary files you can also use the read function.
+
+ read( INPUT, $var, -s INPUT );
+
+The third argument tests the byte size of the data on the INPUT filehandle
+and reads that many bytes into the buffer $var.
+
=head2 How can I read in a file by paragraphs?
Use the C<$/> variable (see L<perlvar> for details). You can either
diff --git a/pod/perlfaq6.pod b/pod/perlfaq6.pod
index dd76588ec0..c4512e695a 100644
--- a/pod/perlfaq6.pod
+++ b/pod/perlfaq6.pod
@@ -9,7 +9,7 @@ littered with answers involving regular expressions. For example,
decoding a URL and checking whether something is a number are handled
with regular expressions, but those answers are found elsewhere in
this document (in L<perlfaq9>: ``How do I decode or create those %-encodings
-on the web'' and L<perlfaq4>: ``How do I determine whether a scalar is
+on the web'' and L<perfaq4>: ``How do I determine whether a scalar is
a number/whole/integer/float'', to be precise).
=head2 How can I hope to use regular expressions without creating illegible and unmaintainable code?