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

[ID 20000324.027] Conditionally evaluated subroutines

From:
James Duncan
Date:
March 24, 2000 06:33
Subject:
[ID 20000324.027] Conditionally evaluated subroutines
Message ID:
38DB7D6E.DF2145B@ebookers.com
This is a bug report for perl from james@epitome.ebookers.com,
generated with the help of perlbug 1.26 running under perl 5.00565.

This is quite a strange one -- I'm not sure if it is a bug, or if it is
intended behaviour.  If it is intended behavior then I'm not sure I
understand why this is the case.

I've run it under several versions of perl, and this code always
results  
in Goodbye being sent to STDOUT, which strikes me as a little strange.

if (1) {
  eval { sub test { print "Hello"; }  }
} else {
  eval { sub test { print "Goodbye" } }
}

test();
__END__

However, the following piece of code works as expected:

if (1) {
  eval 'sub test { print "Hello" };'
} else {
  eval 'sub test { print "Goodbye" };'
}

test();
__END__


[Please do not change anything below this line]
-----------------------------------------------------------------

---
This perlbug was built using Perl 5.00503 - Fri Oct  1 13:09:46 IST 1999
It is being executed now by  Perl 5.00565 - Tue Feb 29 19:36:30 GMT
2000.

Site configuration information for perl 5.00565:

Configured by james at Tue Feb 29 19:36:30 GMT 2000.

Summary of my perl5 (revision 5.0 version 5 subversion 650)
configuration:
  Platform:
    osname=linux, osvers=2.2.5-15smp, archname=i686-linux-thread-multi
    uname='linux epitome.ebookers.com 2.2.5-15smp #1 smp mon apr 19
22:43:28 edt 1999 i686 unknown '
    config_args='-ds -e -DDEBUGGING -Dusethreads -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
    usesocks=undef useperlio=undef d_sfio=undef
    use64bits=undef uselargefiles=define usemultiplicity=define
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux
(egcs-1.1.2 release)
    cppflags='-D_REENTRANT -Dbool=char -DHAS_BOOL -fno-strict-aliasing
-I/usr/local/include'
    ccflags ='-D_REENTRANT -Dbool=char -DHAS_BOOL -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
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lpthread -lc -lposix -lcrypt
    libc=/lib/libc-2.1.1.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 5.00565:
    /usr/local/lib/perl5/5.5.650/i686-linux-thread-multi
    /usr/local/lib/perl5/5.5.650
    /usr/local/lib/perl5/site_perl/5.5.650/i686-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.5.650
    /usr/local/lib/perl5/site_perl/5.00558
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl 5.00565:
    HOME=/home/james
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/usr/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/X11R6/bin:/opt/kde/bin:/home/james/bin:/opt/kde/bin:/usr/X11R6/bin:/opt/kde/bin:/home/james/bin:/opt/kde/bin:/opt/kde/bin:/opt/kde/bin:/opt/kde/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About