i.e This works SIG{INT} = \&gracefulExit; This doesn't work SIG{INT} = "$self->gracefulExit"; ################ package abc sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub initialize { my $self = shift; $SIG{INT} = "$self->gracefulExit"; } sub gracefulExit { my $self = shift; # Cleanup exit(); } 1 ################ # start of script use abc; $test = new abc(); $test->initialize(); # Control- C returns ... SIGINT handler "abc=HASH(0x229c34)->gracefulExit" not defined. I'm not sure why this is so, appreciate the help guys.
In reply to Signal calling to object method by markusk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |