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; }
Oddly enough, it does work on individual hash and array elements, even when those hashes and arrays are lexicals!Can't localize lexical variable $foo at ...
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...my %hash = (a => 'one', b => 'two', c => 'three' ); use Data::Dumper; { local $hash{b} = 'Hello!'; print Dumper \%hash; } print Dumper \%hash;
In reply to Re: Re: Signals and 'IGNORE'
by bart
in thread Signals and 'IGNORE'
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |