Running:
$t = 3;
{
tie $t, 'Yep';
} # Expect $t to become untied here.
print $t;
package Yep;
sub TIESCALAR {
bless {}, 'Yep';
}
sub UNTIE {
print "UNTIE\n";
}
sub DESTROY {
print "DESTROY\n";
}
The output is:
Can't locate object method "FETCH" via package "Yep" at a.pl line 5.
DESTROY
The EXPECTED output is:
DESTROY
3
I want to tie
variable $t only for the duration of the scope in which tie
is located. Out of the scope it must behave same as before tie. So I wrap tie
into the block and expect that untie
will be called when the end of block is reached (like 'local' where the value is restored at the end of block, but for tied variable I expect behaviour is restored (untie $t
) ). Notice the $t
is not out of scope yet.