develooper Front page | perl.perl5.porters | Postings from July 2011

Re: [PATCH] [DOCS] Modernize perlopentut.pod

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
July 20, 2011 15:04
Subject:
Re: [PATCH] [DOCS] Modernize perlopentut.pod
Message ID:
20110720220429.GY26428@tozt.net
On Wed, Jul 20, 2011 at 11:57:18PM +0200, Johan Vromans wrote:
> The very first piece of code from the tutorial should be something
> similar to:
> 
>   In general, the way to open a file, read it contents, and write it to
>   another file goes like this:
> 
>      open( STDIN,  '< :encoding(utf-8)', 'data.file' ) or die;
>      open( STDOUT, '> :encoding(utf-8)', 'new.file'  ) or die;
>      while ( <> ) {
>         # do something with contents
>         print($_) or die;
>      }
>      close(STDOUT) or die;
>      close(STDIN) or die;

Well, I don't think that the very first example should include reopening
STDIN/OUT, especially without mentioning the issues that that could
cause (what happens if "do something with contents" involves prompting
for input?). Otherwise, yes, I agree entirely.

-doy

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