in reply to END blocks created at run time?
For the general construct though, END blocks are the wrong answer. They fire when Perl stops running, not before you exit your subroutine. Instead you probably wanted to use ReleaseAction...
UPDATE
bbfu is right about when the delete should happen. But
you could still use ReleaseAction as follows:
Now whenever $fh goes away, the file is deleted. (There may be an order of action issue though.)-:$$$fh = ReleaseAction->new( sub {unlink $file or die "Cannot unlink $file: $!"} );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(bbfu) Re (tilly) 1: END blocks created at run time?
by bbfu (Curate) on May 08, 2001 at 04:15 UTC |