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

Re: Pre-RFC: ${^OUTPUT_HANDLE}

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
October 22, 2021 15:19
Subject:
Re: Pre-RFC: ${^OUTPUT_HANDLE}
Message ID:
20211022161929.44979519@shy.leonerd.org.uk
On Fri, 22 Oct 2021 23:11:38 +0800
Tom Molesworth via perl5-porters <perl5-porters@perl.org> wrote:

> On Fri, 22 Oct 2021 at 22:50, Paul "LeoNerd" Evans
> <leonerd@leonerd.org.uk> wrote:
> 
> > I propose the addition of a new perlvar; perhaps named
> >
> >   {
> >     local ${^OUTPUT_HANDLE} = $newh;
> >     print "Things";
> >   }
> >  
> 
> Wouldn't the existing STDOUT local() support be more clear for this
> case? It also has the advantage of working equivalently for
> STDERR/warn:
> 
> {
>  local *STDOUT = $newh;
>  print "Redirected";
> }
> {
>  local *STDERR = $newh;
>  warn "Also redirected";
> }
> 
> Or is this aimed more at format-related functionality?

Wow. I had actually forgotten you can do that.

Turns out that's perfectly fine for my use-case, which was a small
unit-test around a print'ing method. I shall do that instead.


The prosecution rests, your Honour.

-- 
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