Front page | perl.perl5.porters |
Postings from October 2003
[perl #24296] scalars and hashes sometimes not available in quoted evals in END blocks
From:
David Dyck
Date:
October 27, 2003 20:30
Subject:
[perl #24296] scalars and hashes sometimes not available in quoted evals in END blocks
Message ID:
rt-24296-66495.19.2925164618972@rt.perl.org
# New Ticket Created by David Dyck
# Please include the string: [perl #24296]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24296 >
This is a bug report for perl from david.dyck@fluke.com,
generated with the help of perlbug 1.34 running under perl v5.9.0.
-----------------------------------------------------------------
[Please enter your report here]
I had a scripting tool that used perl, and recently
discovered that when I eval a single-quoted string q{}
called from an END block the variable is not accessable,
even though it still has a value.
Please notice how the scalar $my_scalar is not "available"
for a short while when called from the END block, but
it should be, as it still exists and has a value.
This case doesn't seem to be covered in perldiag's documentation
for this warning.
(removing the q allows the code to appear to work, but in
my case, the string I want to eval is not known until the
END block is executed, hence the single-quote string)
#!/usr/local/bin/perl -w
$|=1;
use strict;
my $my_scalar = "my_scalar";
sub showvars
{
eval q{ print "my_scalar=$my_scalar\n" ; };
warn "$@" if length $@;
}
END {
print "END\n";
showvars;
print "my_scalar=$my_scalar\n";
}
showvars;
__END__
my_scalar=my_scalar
END
Variable "$my_scalar" is not available at (eval 2) line 1.
Use of uninitialized value in concatenation (.) or string at (eval 2) line 1.
my_scalar=
my_scalar=my_scalar
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=high
---
Site configuration information for perl v5.9.0:
Configured by dcd at Wed Oct 15 06:44:59 PDT 2003.
Summary of my perl5 (revision 5.0 version 9 subversion 0 patch 21452) configuration:
Platform:
osname=linux, osvers=2.4.23pre1, archname=i686-linux
uname='linux dd 2.4.23pre1 #2 wed aug 27 11:20:37 pdt 2003 i686 '
config_args='-Dmksymlinks -Dinstallusrbinperl -Uversiononly -Dusedevel -Doptimize=-O3 -g -de -Dcf_email=david.dyck@fluke.com'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3 -g',
cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='egcs-2.91.66.1 19990314/Linux (egcs-1.1.2 release)', 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=4
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -ldbm -ldb -ldl -lm -lc
perllibs=-ldl -lm -lc
libc=/lib/libc.so.5.4.44, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
DEVEL21398
---
@INC for perl v5.9.0:
/usr/local/lib/perl5/5.9.0/i686-linux
/usr/local/lib/perl5/5.9.0
/usr/local/lib/perl5/site_perl/5.9.0/i686-linux
/usr/local/lib/perl5/site_perl/5.9.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl
.
---
Environment for perl v5.9.0:
HOME=/home/dcd
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/dcd/bin:/sbin:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/games:/usr/local/samba:/home/hobbes/tools/scripts:/home/hobbes/tools/linux:/usr0/hobbes/tools/scripts:/usr0/dcd/bin:/apps/general/bin:/usr/public
PERL5_CPANPLUS_CONFIG=/home/dcd/.cpanplus/config
PERL_BADLANG (unset)
SHELL=/bin/bash
-
[perl #24296] scalars and hashes sometimes not available in quoted evals in END blocks
by David Dyck