summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorDominic Dunlop <domo@slipper.ip.lu>1997-06-16 11:36:14 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit08e9d68e93f9880dc9a1edcde3abb85026f49784 (patch)
tree91b1649fae5e4a3033997482c0e2c988f8e0af20 /pod
parent7bc39d6220d2b77d9c5827625d97cd2af6ef9c56 (diff)
downloadperl-08e9d68e93f9880dc9a1edcde3abb85026f49784.tar.gz
-p does not check for failure of implicit print
Unlike modern incarnations of, say, awk and sed, perl -p does not check the return status of the implicit print statement executed for each input record. Here's a patch against 5.004_01. ('ware wrapping: there's a long line in it.) There's no test case: I couldn't think up a reliable, portable and polite way of inducing a write error. I think, in the specific case of the implicit print in -p, this is non-controversial, and can go in the maintenance branch. That's not to say that there are not programs using -p out there (probably CGI scripts) which will surprise people by exiting noisily on encountering an error, rather than continuing to do thewrong thing quietly. Does anybody know of any widespread examples? Do we care? More controversial error checking patch for implicit close of <ARGV> to follow in separate bug report. p5p-msgid: v0311070aafea3fa83061@[194.51.248.75]
Diffstat (limited to 'pod')
-rw-r--r--pod/perldiag.pod13
-rw-r--r--pod/perlrun.pod15
2 files changed, 21 insertions, 7 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index d3ea144e0e..ab40fd122d 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -153,6 +153,12 @@ which provides a race condition that breaks security.
(F) Perl can't peek at the stdio buffer of filehandles when it doesn't
know about your kind of stdio. You'll have to use a filename instead.
+=item C<-p> destination: %s
+
+(F) An error occurred during the implicit output invoked by the C<-p>
+command-line switch. (This output goes to STDOUT unless you've
+redirected it with select().)
+
=item 500 Server error
See Server error.
@@ -656,8 +662,11 @@ buffer.
=item Can't open %s: %s
-(S) An inplace edit couldn't open the original file for the indicated reason.
-Usually this is because you don't have read permission for the file.
+(S) The implicit opening of a file through use of the C<E<lt>E<gt>>
+filehandle, either implicitly under the C<-n> or C<-p> command-line
+switches, or explicitly, failed for the indicated reason. Usually this
+is because you don't have read permission for a file which you named
+on the command line.
=item Can't open bidirectional pipe
diff --git a/pod/perlrun.pod b/pod/perlrun.pod
index de7116d939..61e40f88a0 100644
--- a/pod/perlrun.pod
+++ b/pod/perlrun.pod
@@ -376,8 +376,10 @@ B<awk>:
}
Note that the lines are not printed by default. See B<-p> to have
-lines printed. Here is an efficient way to delete all files older than
-a week:
+lines printed. If a file named by an argument cannot be opened for
+some reason, Perl warns you about it, and moves on to the next file.
+
+Here is an efficient way to delete all files older than a week:
find . -mtime +7 -print | perl -nle 'unlink;'
@@ -396,11 +398,14 @@ makes it iterate over filename arguments somewhat like B<sed>:
while (<>) {
... # your script goes here
} continue {
- print;
+ print or die "-p destination: $!\n";
}
-Note that the lines are printed automatically. To suppress printing
-use the B<-n> switch. A B<-p> overrides a B<-n> switch.
+If a file named by an argument cannot be opened for some reason, Perl
+warns you about it, and moves on to the next file. Note that the
+lines are printed automatically. An error occuring during printing is
+treated as fatal. To suppress printing use the B<-n> switch. A B<-p>
+overrides a B<-n> switch.
C<BEGIN> and C<END> blocks may be used to capture control before or after
the implicit loop, just as in awk.