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

[perl #85976] The 'do' function does not clear $! if it fails to compile it's argument

Thread Next
From:
Zbigniew Lukasiak
Date:
March 12, 2011 10:19
Subject:
[perl #85976] The 'do' function does not clear $! if it fails to compile it's argument
Message ID:
rt-3.6.HEAD-4136-1299923292-654.85976-75-0@perl.org
# New Ticket Created by  Zbigniew Lukasiak 
# Please include the string:  [perl #85976]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=85976 >


This is a bug report for perl from zby@cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.3.


-----------------------------------------------------------------
[Please describe your issue here]
Running this code:

do 'example.pl' or print "\$!: $!\n";
print "\$\@: $@\n";

assumming that 'example.pl' in current directory contains:

use NonExisting;

Results in:

$!: No such file or directory
$@: Can't locate NonExisting.pm in @INC (@INC contains:
/home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux
/home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3
/home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/x86_64-linux
/home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3 .) at example.pl line
1.
BEGIN failed--compilation aborted at example.pl line 1.


I.e. both "$!" and "$@" are set.

The documentation of 'do' says:

If "do" cannot read the file, it returns undef and sets $! to
the error.  If "do" can read the file but cannot compile it, it
returns undef and sets an error message in $@.

This does not, strictly speaking, preclude the current behaviour,
but I think most people, if not warned, would understand this to mean
that $! is set only in the case when the file cannot be found.

The current behavious is probably a result of not clearing $!, set
by the failed @INC searches, by "do" after the compilation fails.


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

Configured by zby at Sat Jan 22 22:01:16 CET 2011.

Summary of my perl5 (revision 5 version 12 subversion 3) configuration:

  Platform:
    osname=linux, osvers=2.6.35-24-generic, archname=x86_64-linux
    uname='linux zby 2.6.35-24-generic #42-ubuntu smp thu dec 2 02:41:37 utc
2010 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/zby/perl5/perlbrew/perls/perl-5.12.3'
    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.4.5', 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 -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.12.1.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.12.1'
  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.12.3:

 /home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux
    /home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3
    /home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/x86_64-linux
    /home/zby/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3
    .

---
Environment for perl 5.12.3:
    HOME=/home/zby
    LANG=pl_PL.utf8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

 PATH=/home/zby/perl5/perlbrew/bin:/home/zby/perl5/perlbrew/perls/perl-5.12.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

 PERLBREW_PATH=/home/zby/perl5/perlbrew/bin:/home/zby/perl5/perlbrew/perls/perl-5.12.3/bin
    PERLBREW_PERL=perl-5.12.3
    PERLBREW_ROOT=/home/zby/perl5/perlbrew
    PERLBREW_VERSION=0.13
    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