in reply to Re: Signals and 'IGNORE'
in thread Signals and 'IGNORE'

A more portable solution would be, to remember the value of $SIG{INT} before you set it to 'IGNORE', and restore the old value whenever you want it.
That's precisely what local() is for.

Over the years, people are so wrapped in the discussions of local vs. my, that they tend to forget what a great concept local really is. Unfortunately, it doesn't work on lexical scalars.

my $foo; { local $foo; }
Can't localize lexical variable $foo at ...
Oddly enough, it does work on individual hash and array elements, even when those hashes and arrays are lexicals!
my %hash = (a => 'one', b => 'two', c => 'three' ); use Data::Dumper; { local $hash{b} = 'Hello!'; print Dumper \%hash; } print Dumper \%hash;
Unfortunately, if a localised hash element didn't exist in the outer scope, then when it's restored, it is merely set to undef, not deleted. So you end up with one hash element more than you had before. You can localise the entire hash — if it isn't a lexical, that is; but still...