summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldiag.pod13
-rw-r--r--pod/perlrun.pod15
-rw-r--r--toke.c4
3 files changed, 24 insertions, 8 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.
diff --git a/toke.c b/toke.c
index c5c32bf0e3..f443af7442 100644
--- a/toke.c
+++ b/toke.c
@@ -369,7 +369,9 @@ register char *s;
return s;
if ((s = filter_gets(linestr, rsfp, (prevlen = SvCUR(linestr)))) == Nullch) {
if (minus_n || minus_p) {
- sv_setpv(linestr,minus_p ? ";}continue{print" : "");
+ sv_setpv(linestr,minus_p ?
+ ";}continue{print or die qq(-p destination: $!\\n)" :
+ "");
sv_catpv(linestr,";}");
minus_n = minus_p = 0;
}