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

[perl #83082] New style indirect glob slot assignment ($x=\*h;*$x=\5;) to perldelta

Zsban Ambrus
January 31, 2011 01:50
[perl #83082] New style indirect glob slot assignment ($x=\*h;*$x=\5;) to perldelta
Message ID:
# New Ticket Created by  Zsban Ambrus 
# Please include the string:  [perl #83082]
# 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.39 running under perl 5.12.3.

[Please describe your issue here]

In perl 5.12.* and 5.10.*, if you wish to assign to a typeglob slot
indirectly (with strict "refs" active), you have to glob dereference a
glob reference on the left side of the equals sign.  For example,
'$x = \*h; *$x = \5;' has the same effect as '*h = \5;', namely
changing the package scalar variable $h to point to a new place.
Somewhere in perl 5.13 before 5.13.9, a simpler alternative is introduced:
you can now simply glob dereference a glob, so '$x = *h; *$x = \5;'
is also equivalent to the above.  The old method of using a glob reference
still works of course.

(All this, of course, does not only apply to assigning to the scalar slot,
but also to other lots, such as array, hash, code etc.)

I approve this change because it is consistent with how glob dereferencing
works as an rvalue: *$x got the glob no matter whether $x is a glob
reference or a glob (or a symbolic reference or an IO handle).  In fact,
because glob dereferencing has always worked like this, I would expect
that glob assignment works this way too.  This, however, means that this
change should be documented clearly in the perldeltas: both in one of
perl513?delta and in the future delta for perl 5.14.0.  If this is not
documented, someone could use this new feature in code he or she writes
and the get strange bugs if the code is ran in older perls.  This is
even more true because a new style glob slot assignment is completely
silent in older perls, so you don't get an early die or warning.

You'll have to excuse my not writing a patch, because I'm not too familiar
in how all this typeglob magic works, and don't want to lie about the

Thanks in advance,


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

Configured by ambrus at Tue Jan 25 14:12:12 CET 2011.

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

    osname=linux, osvers=, archname=x86_64-linux
    uname='linux king #1 smp sat jul 10 18:21:56 cest 2010
x86_64 gnulinux '
    config_args='-Dinc_version_list=5.12.2/x86_64-linux 5.12.2
5.12.1/x86_64-linux 5.12.1 5.12.0/x86_64-linux 5.12.0 -d'
    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
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.5.1', 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',
    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 /usr/local/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib

Locally applied patches:

@INC for perl 5.12.3:

Environment for perl 5.12.3:
    LANG (unset)
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About