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

[perl #22297] cannot untie scalar from within tied FETCH

May 23, 2003 17:02
[perl #22297] cannot untie scalar from within tied FETCH
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #22297]
# 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]

I've found that it doesn't seem possible to untie a scalar
from within a tied FETCH routine.  It is possible to untie
hashes from within a hashes FETCH route.

Before there are any objections that this is a silly thing to
do, consider tieing a variable in order to demand load its 
value from a persistant store.  After the value is loaded, 
the variable needs to be untied.

I include a test program that demonstrates the problem.

I would be happy with a work-around.  


-------- cut here ----------
#!/usr/bin/perl -I.

my $counter = 0;
print "1..1\n";
my $x = 7;
my $ref = \$x;
tie $x, 'Overlay', $ref, $x;
my $y;
$y = $x;
$y = $x;
$y = $x;
$y = $x;
#print "WILL EXTERNAL UNTIE $ref\n";
untie $$ref;
$y = $x;
$y = $x;
$y = $x;
$y = $x;
#print "counter = $counter\n";

print (($counter == 1) ? "ok 1\n" : "not ok 1\n");

package Overlay;

	my $pkg = shift;
	my ($ref, $val) = @_;
	return bless [ $ref, $val ], $pkg;

	my $self = shift;
	my ($ref, $val) = @$self;
	#print "WILL INTERNAL UNITE $ref\n";
	untie $$ref;
	return $val;
-------- cut here ----------

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

Configured by muir at Wed Dec 18 00:21:13 PST 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
    osname=freebsd, osvers=4.7-release, archname=i386-freebsd
    uname='freebsd 4.7-release freebsd 4.7-release #4: thu oct 10 22:04:24 pdt 2002 i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.0/mach -Dprivlib=/usr/local/lib/perl5/5.8.0 -Dman3dir=/usr/local/lib/perl5/5.8.0/man/man3 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.0/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.0 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -Ui_gdbm -Dusemymalloc=n'
    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=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include',
    optimize='-O -pipe -m486 -mcpu=i686 -march=pentiumpro ',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.4 20020320 [FreeBSD]', 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=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lgdbm -lm -lc -lcrypt -lutil
    perllibs=-lm -lc -lcrypt -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.0:

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