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

[perl #8826] Document '-' as the argument to open

Thread Previous | Thread Next
James E Keenan via RT
December 31, 2011 05:45
[perl #8826] Document '-' as the argument to open
Message ID:
On Mon Mar 11 04:16:33 2002, wrote:
> This is a bug report for perl from "Anton Tagunov" <>
> generated with the help of perlbug 1.33 running under perl v5.7.3.
> -----------------------------------------------------------------
> Hello, developers!
> I have discovered some peculiarities with '-' argument to open,
> and (Yitzchak Scott-Thoennes)  (bs"d) has confirmed
> that:
> YST> V, '-' seems to be equivalent to
> YST>*V = *STDIN{IO}; close V then seems to do absolutely
> YST>nothing. close STDIN, on the other hand, closes the
> YST>in-file-pointer shared by V and STDIN.

Reviewing this older ticket, I noticed that there was no code example
provided.  I wrote the following, but it does not seem to support the
original poster's contention that "close V then seems to do absolutely
nothing." (Using Perl 5.14.2 on Darwin/PPC.)

$ cat
use strict;
use warnings;

open V, '-';
for (my $i=0; $i<=2; $i++) {
    my $line = <V>;
    print $line;
close V;

my $next_line = <V>;
print $next_line;

$ cat lines

$ cat lines | perl ./
readline() on closed filehandle V at ./ line 12.
Use of uninitialized value $next_line in print at ./ line 13.

If the filehandle has indeed been closed, then there's no need for the
documentation patch the poster suggested.  Thoughts?

Thank you very much.
Jim Keenan

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About