Duration:
$t = 3;
{
tie $t, 'Yep';
}
print $t;
package Yep;
sub TIESCALAR {
bless {}, 'Yep';
}
sub UNTIE {
print "UNTIE\n";
}
sub DESTROY {
print "DESTROY\n";
}
Output:
Can't locate object method "FETCH" via package "Yep" at a.pl line 5.
DESTROY
Output EXPECTED:
DESTROY
3
I want the tievariable $ t only for the duration of the area it is in tie. Out of scope, he should behave the same as before a tie. Therefore, I transfer tieto the block and expect it to untiebe called when the end of the block is reached (for example, "local", where the value is restored at the end of the block, but for the bound variable, I expect the behavior to be restored ( untie $t)). Please note that $tis not beyond the scope.
source
share