develooper Front page | perl.perl5.porters | Postings from May 2003

Re: [PATCH] [perl #8602] Clarify eof() example comments

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
May 9, 2003 13:40
Subject:
Re: [PATCH] [perl #8602] Clarify eof() example comments
Message ID:
20030509224631.0651d567.rgarciasuarez@free.fr
Casey West wrote:
> --- perl-current.orig/pod/perlfunc.pod  Fri May  9 00:58:19 2003
> +++ perl-current/pod/perlfunc.pod       Fri May  9 07:35:51 2003
> @@ -1326,9 +1326,9 @@
>  
>      # insert dashes just before last line of last file
>      while (<>) {
> -       if (eof()) {            # check for end of current file
> +       if (eof()) {            # check for end of last file
>             print "--------------\n";
> -           close(ARGV);        # close or last; is needed if we
> +           close(ARGV);        # either close or last is needed if we
>                                 # are reading from the terminal

I disagree with that 2nd change.
I don't see the point of closing ARGV is we don't read from STDIN, because
$. isn't used. And if reading from STDIN, exiting the loop should be
done after the C<print> :

>         }
>         print;

I propose :

    while (<>) {
	if (eof()) {    # check for end of last file
            print "--------------\n";
	}
	print;
	last if eof();  # needed if we're reading from the terminal
    }

-- 
Unsent is not *NIX

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About