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