Robin Redeker writes: > This should actually be, to prevent the resource from leaking: > > { > my $s = new CoolClass; > eval { > ... do stuff that may throws ... > }; > destroy $s; > }
Or, with the "block hooks" that I keep claiming makes timely destruction almost never needed, it is: { my $s = new CoolClass; # ... do stuff that may throw ... LEAVE { destroy $s } } This destroys properly and even propagates the exception. Luke