ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
16.16. Temporarily Overriding a Signal HandlerProblemYou want to install a signal handler only for a particular subroutine. For instance, your subroutine catches SIGINT, and you don't want to disturb SIGINT handling outside the subroutine. SolutionUse # the signal handler sub ding { $SIG{INT} = \&ding; warn "\aEnter your name!\n"; } # prompt for name, overriding SIGINT sub get_name { local $SIG{INT} = \&ding; my $name; print "Kindly Stranger, please enter your name: "; chomp( $name = <> ); return $name; } DiscussionYou must use |