develooper Front page | perl.perl5.porters | Postings from November 2009

[perl #70449] bug affecting $! when readline() is used in array context

Thread Next
From:
root@theale.wetafx.co.nz
Date:
November 13, 2009 01:41
Subject:
[perl #70449] bug affecting $! when readline() is used in array context
Message ID:
rt-3.6.HEAD-26055-1258064876-538.70449-75-0@perl.org
# New Ticket Created by  root@theale.wetafx.co.nz 
# Please include the string:  [perl #70449]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=70449 >



This is a bug report for perl from bhall@twetafx.co.nz,
generated with the help of perlbug 1.39 running under perl 5.10.1.


-----------------------------------------------------------------
[Please describe your issue here]

Hi,

Here is an issue with the perl interpreter:

my $ret = open(FH, "sample.txt");
undef $!;
my @arr = <FH>; # or readline(FH)
if ($!) {
warn "Error $!";
}
close(FH);

If the file "sample.txt" does not have a new line character at the end of the
last text line in the file, a "Bad file descriptor" error will be printed.

This means it is impossible to use readline() in an array context, because you
cannot reliably check for errors.


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

Configured by root at Fri Nov 13 10:48:03 NZDT 2009.

Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=2.6.25.18-wetanfs-20081021, archname=x86_64-linux
    uname='linux theale 2.6.25.18-wetanfs-20081021 #1 smp tue oct 21 09:38:06 nzdt 2008 x86_64 gnulinux '
    config_args='-de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.1.2 (Ubuntu 4.1.2-0ubuntu4)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.5.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.10.1:
    /usr/local/lib/perl5/5.10.1/x86_64-linux
    /usr/local/lib/perl5/5.10.1
    /usr/local/lib/perl5/site_perl/5.10.1/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.10.1
    .

---
Environment for perl 5.10.1:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/root/bin
    PERL5LIB (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


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