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

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

From:
James E Keenan via perl5-changes
Date:
August 10, 2022 14:39
Subject:
[Perl/perl5] 4d4eaa: Document C<local *STDOUT> as an alternative toC<s...
Message ID:
Perl/perl5/push/refs/heads/blead/3fd12c-4d4eaa@github.com
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 4d4eaa2cb3eb05793dc301178e47fe89488a88f0
      https://github.com/Perl/perl5/commit/4d4eaa2cb3eb05793dc301178e47fe89488a88f0
  Author: James E Keenan <jkeenan@cpan.org>
  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: https://github.com/Perl/perl5/pull/19225; reconciling different
approaches developed by @nwc10 and @leonerd.





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About