in reply to The aftermath of an untie

Howdy!

Under 5.004_04, I was able to strip this down even further and get the same output from the untie.

#!/bin/perl -w use strict; package Tied; sub TIESCALAR { my $class = shift; my $o = shift; bless \$o, $class; } sub FETCH { my $self = shift; print "<fetch>\n"; $self; } sub foo {"TiedFoo\n";} package main; my $o; tie $o, 'Tied'; print $o->foo(); untie $o; eval { print $o->foo() }; print "NoFoo\n" if $@;

In the end, $o was still tied.

yours,
Herveus

Replies are listed 'Best First'.
Re: Re: The aftermath of an untie
by dws (Chancellor) on Oct 08, 2001 at 12:03 UTC
    In the end, $o was still tied.

    Ah, but it isn't. $o is still associated with Tied, but the tie itself has been undone, as evidenced by the absense of a <fetch> message from the final invocation of $o->foo().

    That's the oddity I've noticed about untie -- the association with the Tied class is still there (i.e., the variable is still blessed), even though the variable is no longer tied. I have yet to find this behavior documented.