develooper Front page | perl.perl5.porters | Postings from November 2010

Re: [perl #79828] STDERR isn't being unlocalized when there's an unhandled exception.

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
November 28, 2010 17:20
Subject:
Re: [perl #79828] STDERR isn't being unlocalized when there's an unhandled exception.
Message ID:
29183.1290993588@chthon
>> But it *hasn't* left that scope:

>> It is still within scope.

> But it shouldn't be.  

Says who?  Perl understands scopes perfectly well.

          sub foo {
              die q<why doesn't this show up?>;
          }
     
          sub bar {
              my $x;
              open my $h, '>', \$x;
              local *STDERR = $h;
              foo();
          }
     
          bar();

At runtime:

     1	main calls bar()
     2	    bar() sets stderr alias to last until bar's scope is over.
     3	    bar calls foo()
     4		foo() calls die()
     5		    die() writes to stderr

The bar() scope set up at 2 is *clearly* still extant at
stage 5.  Notice the indentation.  There is no question 
that Perl is behaving per design and documentation.

It may not be doing what *you* expect it to, but that is 
an entirely separate matter.

--tom

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