{ local *IO::Handle::DESTROY = sub { ... }; { open my $fh, "..."; ... } # will trigger here }