Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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 avoiding work at the Monastery: (4)
As of 2016-02-13 15:58 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (438 votes), past polls