Indomitus has asked for the wisdom of the Perl Monks concerning the following question:
What is the scope of a variable called with my in a signal handler anonymous subroutine? Right now I have this code:
elsewhere in the program...my $rip_done = 0; $SIG{CHLD} = sub { $rip_done = 1; while( waitpid(-1, WNOHANG) > 0) {} };
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.if($rip_done == 1) { do some stuff }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Variable Scope in a Signal Handler?
by Fastolfe (Vicar) on Nov 01, 2001 at 22:02 UTC |
Back to
Seekers of Perl Wisdom