develooper Front page | perl.perl5.porters | Postings from June 2020

Re: What am I not grokking about $SIG{__WARN__}?

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 30, 2020 13:44
Subject:
Re: What am I not grokking about $SIG{__WARN__}?
Message ID:
20200630144412.40272398@shy.leonerd.org.uk
On Tue, 30 Jun 2020 09:38:16 -0400
James E Keenan <jkeenan@pobox.com> wrote:

> BEGIN { local $SIG{__WARN__} = sub { $thiswarn = $_[0]; }; }

The local scope ends as soon as the BEGIN block ends. Thus that didn't
ever catch anything.

It's really nontrivial to `local`y capture warnings at compiletime. You
can't use `local` inside a BEGIN block, because of this.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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