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

[ID 20020115.001] *FILE{IO} does not behave like *FILE for stat()and -X() operators

Thread Next
From:
Jamie Lokier
Date:
January 15, 2002 08:10
Subject:
[ID 20020115.001] *FILE{IO} does not behave like *FILE for stat()and -X() operators
Message ID:
20020115160658.A26955@kushida.apsleyroad.org
This is a bug report for perl from jamie@shareable.org,
generated with the help of perlbug 1.28 running under perl v5.6.0.


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

I use the following code to generate file handles, as per the perlref manpage:

  local *FILE;
  open FILE, "<blahblah" or die "Error opening \`blahblah': $!\n";
  return *FILE{IO};

For the most part, this has the same effect as returning *FILE, and
seems cleaner.  The perlref manpage seems to recommend this, although
the perlfaq5 page seems to prefer the *FILE approach.

Although this works fine with functions like `read', `write', `sysread'
etc., it generates an unexpected result with `stat', `lstat' and the
`-X' file test operators.

Specifically, when one of these *FILE{IO} references is used in the file
test functions, including `stat' and `lstat', it's converted to a string
(i.e. "IO::Handle=IO(0x12345678)"), and that is used as the file name to
test.

On the other hand, when a typeglob *FILE is used in a file test
function, the fstat() system call is used on the open file as expected.

Is this a code discrepancy or something that should be documented in the
perlfunc manpage?

Cheers,
-- Jamie Lokier

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

Configured by bhcompile at Thu Aug  9 22:47:55 EDT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.6-3.1enterprise, archname=i386-linux
    uname='linux stripples.devel.redhat.com 2.4.6-3.1enterprise #1 smp tue jul 24 14:03:17 edt 2001 i686 unknown '
    config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dcc=gcc -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Uuselargefiles'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=undef 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='gcc', optimize='-O2 -march=i386 -mcpu=i686', gccversion=2.96 20000731 (Red Hat Linux 7.1 2.96-96)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc-2.2.4.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:
    

---
@INC for perl v5.6.0:
    /usr/lib/perl5/5.6.0/i386-linux
    /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/i386-linux
    /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/home/jamie
    LANG=en_GB
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/jamie/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/jamie/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