in reply to Re^2: How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
in thread How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
Nevermind. die in destrutor. Doesn't work.
use strict; use warnings; use ReleaseAction qw( on_release ); $| = 1; sub something { my $closer = on_release { print "on_release enter\n"; die("test"); print "on_release exit\n"; }; } print "pre\n"; something(); print "post\n";
outputs
pre on_release enter (in cleanup) test at script.pl line 11. post
Tested on 5.6.1 & 5.8.8
|
|---|