in reply to can't assign signal handler an undef value
my $intr = 0; my $save_handler = $SIG{INT}; $SIG{INT} = sub { $intr++ }; # do something here ... $SIG{INT} = $save_handler || ''; # assign handler back if true, els +e '' # check value of $intr to see if I was interrupted...
update:
Well, there is something special about the %SIG hash. It's not just a normal hash, because it is the %SIG hash. Assignments have to be defined (an empty string is false, but still defined), and the keys are fixed. E.g. you can't just make up signals:
qwurx [shmem] ~ > perl -wle '$SIG{BLORF} = undef' No such signal: SIGBLORF at -e line 1.
You could also say
my $save_handler = $SIG{INT} || '';
to have a defined (but empty) value in $save_handler.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|