I'm pretty new at this, and I'm trying to figure out how Perl's classes work with signals.
Specifically, it doesn't seem that a class's DESTROY function is called when you Ctrl-C the program.
I tried using use sigtrap qw(handler DESTROY INT QUIT);
, but I'm not even sure this is the proper way to catch the signal. Either way, it seems I no longer receive a reference to my object when DESTROY is called. I keep getting this error:
Can't locate object method "time_passed" via package "INT" (perhaps you forgot to load "INT"?) at /var/local/bush/lib/ASH/Basic.pm line 113.
Here is my DESTROY function:
sub DESTROY {
my $self = shift;
my $runtime = time_passed();
print "Total run time: $runtime\n";
close(ERR);
close(WARN);
-d $self->{DIR}{THRESHOLD} ? print "All files saved to $self->{DIR}{THRESHOLD}.\n" : print "Self destroyed.\n";
die("done.\n\n");
}
Thanks for the help!