Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003018]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-02-21 05:49 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (307 votes). Check out past polls.