On Fri May 21 17:22:21 2004, ysth wrote:
> On Fri, May 21, 2004 at 05:13:02PM -0500, david nicol
> <whatever@davidnicol.com> wrote:
> >
> >
> > Right. How's this? The inconsistency of END under -i is due to
> > implementation details as definition of this behavior was never
> > a goal. We can document it as follows:
> >
> >
> > $ perl -pi~ -e 's/foo/bar/' file1 file2 file3...
> >
> > +Code within C<BEGIN> blocks executes before the B<-i> switch takes
> > +effect. The disposition of STDOUT in an C<END> block running under
> > +B<-i> is not defined.
>
> I don't like that; it *is* well defined. It just has nothing to do
> with scope, and everything to do with readline and eof(). And -i
> applies whenever and however you readline from ARGV/check eof(). It
> is certainly possible to do so in a BEGIN block.
>
> Perhaps the -i documentation could just have an example:
>
> #!/usr/bin/perl -pi.bak -w
> BEGIN { print "Processing files: @ARGV\n" }
> $lines_changed++ if s/foo/bar/g;
> END { print "$lines_changed total lines changed\n" }
>
> that clearly shows output going to STDOUT in a normal case?
>
> And the implicit-select effects of readline and eof() should be
> documented with <> in perlop.
>
I don't think that the note proposed in this ticket ever made it to
perlrun; However, the section that starts with "From the shell, saying"
and ends in "Note that STDOUT is restored as the default output
filehandle after the loop." covers pretty much everything discussed in
this ticket, so I vote to close this. If someone still wants a further
clarification in the docs, they are free to send in patches :)
---
via perlbug: queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=29675