develooper Front page | perl.perl5.porters | Postings from September 2010

Why no warning on reading from pipe opened for writing?

From:
Peter Scott
Date:
September 5, 2010 20:14
Subject:
Why no warning on reading from pipe opened for writing?
Message ID:
20100906031401.17631.qmail@lists-nntp.develooper.com
Given this:

$ ./perl -wle 'open $fh, ">", "/tmp/foo"; print for <$fh>'
Filehandle $fh opened only for output at -e line 1.

Why no such warning here:

$ ./perl -wle 'open $fh, "|-", "true"; print for <$fh>'

?  Doesn't Perl know that $fh is only for writing?

Verified on perl 5, version 13, subversion 4 (v5.13.4-144-gf1dcae2) built 
for i686-linux.

-- 
Peter Scott



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