in reply to Something like an object node

If the intention is to ensure some cleanup code is executed even on abnormal exit, I'd suggest translating to a slightly different approach: in the code, rather than setting a variable on error simply call die(), and specify the cleanup in an END block:

END { # your cleanup code here } ... open($fh, '<', $file) or die "Couldn't open $file: $!";

The END block will be executed before the script exits, even after a die(), as long as it isn't bypassed either with a POSIX::_exit() or a core dump.

Using a tied variable to trigger this sort of behaviour involves much subtler action-at-a-distance that would tend (in my experience, at least) to make code much harder to maintain.

Hugo