develooper Front page | perl.perl5.changes | Postings from August 2022

[Perl/perl5] 4d4eaa: Document C<local *STDOUT> as an alternative toC<s...

James E Keenan via perl5-changes
August 10, 2022 14:39
[Perl/perl5] 4d4eaa: Document C<local *STDOUT> as an alternative toC<s...
Message ID:
  Branch: refs/heads/blead
  Commit: 4d4eaa2cb3eb05793dc301178e47fe89488a88f0
  Author: James E Keenan <>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M pod/perlfunc.pod

  Log Message:
  Document C<local *STDOUT> as an alternative to C<select ... select>

If one needs to temporarily "capture" the output of C<print>, for example
as part of a unit test, the classic "obvious" approach has been to use
C<select> before and afterwards, to set a different default output handle
and the restore the previous handle.

If one is already in the mindset of C<select>, it might not be obvious
that C<local *STDOUT> is alternative way to achieve the underlying goal,
and might be clearer and more robust. Hence add it as a suggestion in the
C<select> documentation.

For:; reconciling different
approaches developed by @nwc10 and @leonerd. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About