perlnewbie9292
Programmer
Hello Perl experts,
I am pretty new to Perl and trying to figure out how to do the following.
I have a script which I've added a subroutine that intercepts $SIG{INT} (control -c) key combination.
Now is there anyway/how can I tell my subroutine to get to a certain point in the script (exit(0) using code below) or wait until the script has completed running before exiting?
What I want to avoid is when someone hits control-c the script finishes what it's doing before quitting, this way if it's in the middle of processing something is not half done.
Thanks for the help in advance.
I am pretty new to Perl and trying to figure out how to do the following.
I have a script which I've added a subroutine that intercepts $SIG{INT} (control -c) key combination.
Now is there anyway/how can I tell my subroutine to get to a certain point in the script (exit(0) using code below) or wait until the script has completed running before exiting?
What I want to avoid is when someone hits control-c the script finishes what it's doing before quitting, this way if it's in the middle of processing something is not half done.
Thanks for the help in advance.
Code:
$SIG{INT} = \&waitAndExit;
main();
sub main {
'main program here';
exit(0); #once it gets to this exit(0) then exit.
}
sub waitAndExit {
'what to add here so that this waits until the script gets to the exit(0) above';
}