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

Re: Pre-RFC: ${^OUTPUT_HANDLE}

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
November 9, 2021 16:56
Subject:
Re: Pre-RFC: ${^OUTPUT_HANDLE}
Message ID:
YYqoFU4Z1VmFx77S@etla.org
On Fri, Oct 22, 2021 at 04:19:29PM +0100, Paul "LeoNerd" Evans wrote:
> On Fri, 22 Oct 2021 23:11:38 +0800
> Tom Molesworth via perl5-porters <perl5-porters@perl.org> wrote:

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

"Me too".

(Actually, for me, it's more "I hadn't realised that this would work")

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

I wondered - as it doesn't seem to be "obvious", should we document this?

I'm proposing https://github.com/Perl/perl5/pull/19225

(and now we see whether the cygwin CI test fails on a docpatch)

Nicholas Clark

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