Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-10-14 04:22 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (320 votes), past polls