An END { ... } block can be put into a closure as well:
{ my $fn; do { $fn = tmpnam() } until open ...; END { unlink $fn or warn "Couldn't remove '$fn': $!"; }; };
The die is especially useless indeed - just warning is far saner, as the program is terminating anyway and other cleanup likely doesn't rely on the removal of a temporary file ...
In reply to Re: Tmpnam and END blocks
by Corion
in thread Tmpnam and END blocks
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |