What is the scope of a variable called with my in a signal handler anonymous subroutine? Right now I have this code:
my $rip_done = 0;
$SIG{CHLD} = sub { $rip_done = 1;
while( waitpid(-1, WNOHANG) > 0) {} };
elsewhere in the program...
if($rip_done == 1)
{
do some stuff
}
In the interest of having as few global variables as possible, can I initialize $rip_done inside the sub and still use it elsewhere in the program? I'm still trying to get away from using global variables for everything so I'm not 100% up to snuff on scope yet. I'm also new to signal handlers so if I'm not doing things right here, please let me know. Thanks a lot.