develooper Front page | perl.perl5.porters | Postings from January 2021

Re: local %SIG = (%SIG, $signame => ...) not working as expected?

Thread Previous | Thread Next
From:
Eric Wong
Date:
January 12, 2021 21:11
Subject:
Re: local %SIG = (%SIG, $signame => ...) not working as expected?
Message ID:
20210112211115.GA11058@dcvr
Uri Guttman <uri@stemsystems.com> wrote:
> i wonder why he copies %ENV. he should be able to just do:
> 
>     local( $SIG{$signame} ) = blah ;
> 
> the is faster and doesn't have the odd number thing you mention

Laziness :)  I'm getting a hash(ref) of SIG overrides either as
a return value from another sub.  My workaround is something
like this:

	my %sig = $self->some_callback;
	local $SIG{$_} = $sig->{$_} for keys %sig;
	...

My original (broken) code was this:

	local %SIG = (%SIG, $self->some_callback);

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About