develooper Front page | perl.perl5.porters | Postings from April 2002

[ID 20020420.003] Tie'd STDIN overwritten by open F, "<-"

Thread Next
From:
Mike
Date:
April 20, 2002 16:32
Subject:
[ID 20020420.003] Tie'd STDIN overwritten by open F, "<-"
Message ID:
200204202333.g3KNXvY17368@michael.ms.com

This is a bug report for perl from schilli1@pacbell.net
generated with the help of perlbug 1.33 running under perl v5.7.3.


-----------------------------------------------------------------
[Please enter your report here]

Hey there,

it looks like a tie()d STDIN filehandle gets overwritten if you call
open(FOO, "<-") and use FOO from then on. Somehow it reverts back to
the original STDIN instead of using the tie()d one.

Here's an example that works OK:

    package TieFH;

    sub TIEHANDLE {
        my($class) = @_;
        my $active = 1;
        bless \$active, $class;
    }

    sub READLINE {
        my($self) = @_;
        return $$self-- > 0 ? "abc\n" : undef;
    }

    package main;

    tie(*STDIN,'TieFH');

    while(<STDIN>) {
        print "stdin: $_";
    }
This reads "abc\n" once from the tie()d filehandle and then terminates.
Now, if you replace the last three lines by the four lines below,
you'll see that the while loop gets stuck because it waits for the
*real* STDIN:

    open FOO, "<-" or die "Cannot open";
    while(<FOO>) {
        print "foo: $_";
    }

Shouldn't FOO inherit the tie()d STDIN's properties after the open()?

-- Mike

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.7.3:

Configured by mschilli at Sat Apr 20 16:03:29 PDT 2002.

Summary of my perl5 (revision 5.0 version 7 subversion 3 patch 15876) configuration:
  Platform:
    osname=linux, osvers=2.4.2-2, archname=i686-linux
    uname='linux michael.ms.com 2.4.2-2 #1 sun apr 8 20:41:30 edt 2001 i686 unknown '
    config_args='-D prefix=/home/mschilli/PERL.bleed -d'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    DEVEL15876

---
@INC for perl v5.7.3:
    /home/mschilli/PERL.bleed/lib/perl5/5.7.3/i686-linux
    /home/mschilli/PERL.bleed/lib/perl5/5.7.3
    /home/mschilli/PERL.bleed/lib/perl5/site_perl/5.7.3/i686-linux
    /home/mschilli/PERL.bleed/lib/perl5/site_perl/5.7.3
    /home/mschilli/PERL.bleed/lib/perl5/site_perl
    .

---
Environment for perl v5.7.3:
    HOME=/home/mschilli
    LANG=en_US
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/local/lib:/home/mschilli/download/xerces-c_1_0_0-linux/lib:/home/mschilli/DEV/grugenheimer/javascript/spidermonkey/lib/js/src/Linux_All_DBG.OBJ
    LOGDIR (unset)
    PATH=.:/home/mschilli/bin:/usr/local/prod/bin:/home/mschilli/PERL/bin:/home/mschilli/teTeX/bin:/home/cm/bin/Linux:/bin:/usr/bin:/home/cm/bin/ksh:/home/cm/bin/ksh/prm:/home/cm/bin/linux:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/andrew/bin:/usr/openwin/bin:/usr/games:.:/home/mschilli/bin:/sbin:/services/bsi/bin:./bin:../bin:/home/mschilli/download/xerces-c_1_0_0-linux/bin:/usr/X11R6/bin:/opt/local/bin:/home/mschilli/INSTALL/framemaker/FM556_linux/bin:/home/mschilli/bin:/home/mschilli/INSTALL/mysql/bin:/home/mschilli/INSTALL/postgresql/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


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