develooper Front page | perl.perl5.porters | Postings from February 2003

[perl #21404] local breaks aliasing

Thread Next
Michael G Schwern
February 28, 2003 07:44
[perl #21404] local breaks aliasing
Message ID:
# New Ticket Created by  Michael G Schwern 
# Please include the string:  [perl #21404]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.34 running under perl v5.8.0.

[Please enter your report here]

#!/usr/bin/perl -wl

$foo = 42;
*bar = \$foo;

print "$bar $foo ". \$bar . ' '. \$foo;

{ local $bar = 23;  print "$bar $foo ". \$bar . ' '. \$foo }
{ local $foo = 23;  print "$bar $foo ". \$bar . ' '. \$foo }

$ perl5.8.0 ~/tmp/bug.plx
42 42 SCALAR(0x569dc) SCALAR(0x569dc)
23 42 SCALAR(0x4c59c) SCALAR(0x569dc)
42 23 SCALAR(0x569dc) SCALAR(0x56a00)

I expected something like

42 42 SCALAR(0x569dc) SCALAR(0x569dc)
23 23 SCALAR(0x4c59c) SCALAR(0x4c59c)
23 23 SCALAR(0x56a00) SCALAR(0x56a00)

If you change "*bar = \$foo" to "*bar = *foo" it works.

Problem appears to be in all modern versions of Perl.

Bug or feature?

This came up because Test::Harness does:

@EXPORT_OK = qw($verbose);

$Verbose = 0;
*verbose = \$Verbose;

For legacy reasons, T::H exports $verbose but I use $Verbose internally 
so I know its a global.

I tried

local $Test::Harness::verbose = 1;

which didn't do what I thought it did

[Please do not change anything below this line]
Site configuration information for perl v5.8.0:

Configured by nwatkiss at Sat Jul 20 11:57:03 PDT 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
    osname=linux, osvers=2.2.14-6.0, archname=alpha-linux
    uname='linux 2.2.14-6.0 #1 tue mar 28 16:56:56 est 2000 alpha unknown '
    config_args='-des -Dprefix=/usr/lang/perl/5.8.0'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/shlib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lposix -lcrypt -lutil
    libc=, 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.8.0:

Environment for perl v5.8.0:
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About