Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Override tempdir DESTROY

by tobyink (Abbot)
on Nov 08, 2012 at 23:00 UTC ( #1003018=note: print w/ replies, xml ) Need Help??


in reply to Override tempdir DESTROY

Subclass File::Temp::Dir and override the DESTROY method. This is somewhat complicated by the fact that File::Temp::Dir doesn't have a traditional constructor.

package My::File::Temp::Dir; use File::Temp (); our @ISA = qw(File::Temp::Dir); sub new { my $class = shift; my $self = File::Temp->newdir(@_); bless $self, $class; } sub DESTROY { my $tempdir = shift; ...; # do stuff $tempdir->SUPER::DESTROY(@_); } 1;

Then, stop using the tempdir function and use My::File::Temp::Dir->new instead.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Override tempdir DESTROY
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003018]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-07-05 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls