diotalevi has asked for the wisdom of the Perl Monks concerning the following question:
I can't recall the name of the module that lets me associate a destructor with a specific thing. I've got an Archive::Extract object which has been extracted out to a temporary directory. I'd like to remove the directory as soon as the last reference to it is gone. The code to do this is simple enough and the need common enough that I'm sure it's already on CPAN but that I just can't recall the name. Help?
$tmpdir = File::Temp::tmpdir(); $archive = Archive::Extract->new( archive => ... ); $archive->extract( to => $tmpdir ); # Hooks DESTROY for this object. $archive = on_cleanup( $archive, sub { # rm -rf $tmpdir } );
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Per-object DESTROY
by Corion (Patriarch) on Jul 07, 2007 at 17:18 UTC | |
|
Re: Per-object DESTROY
by Joost (Canon) on Jul 07, 2007 at 22:29 UTC | |
by diotalevi (Canon) on Jul 08, 2007 at 00:53 UTC | |
by varian (Chaplain) on Jul 08, 2007 at 13:53 UTC | |
by diotalevi (Canon) on Jul 08, 2007 at 18:19 UTC | |
|
Re: Per-object DESTROY
by sgt (Deacon) on Jul 08, 2007 at 14:06 UTC | |
|
Re: Per-object DESTROY
by Anonymous Monk on Jul 08, 2007 at 05:43 UTC | |
|
Re: Per-object DESTROY
by dmitri (Priest) on Jul 12, 2007 at 03:53 UTC |