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

[perl #105658] STDIN <> and PerlIO doc

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
December 8, 2011 09:18
Subject:
[perl #105658] STDIN <> and PerlIO doc
Message ID:
rt-3.6.HEAD-5084-1323364686-1673.105658-15-0@perl.org
On Thu Dec 08 03:25:08 2011, evdokimov.denis@gmail.com wrote:
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my $data = "aaa\nbbb\nccc\n";
> 
> # Ok
> close STDIN or die $!;
> open( STDIN, '<', \$data ) or die $!;
> @ARGV = ();
> while (<STDIN>)
> {
>     print "[[$ARGV]]***$_";
> }
> 
> # Bug
> close STDIN or die $!;
> open( STDIN, '<', \$data ) or die $!;
> @ARGV = ();
> while (<>)
> {
>     # print PerlIO.pod
>     print "[[$ARGV]]***$_";
> }

By closing STDIN you are closing fd 0, which is reused by the next file
opened.

I seem to remember this came up about three years ago and the consensus
was that it is not a bug.  I’m not sure.

If my memory serves me correctly, searching for ‘you passed sub
protections’ and ‘This gotta change’ in the archives will bring it up.

-- 

Father Chrysostomos


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