summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Timmermans <fawaka@gmail.com>2021-01-20 00:37:54 +0100
committerLeon Timmermans <fawaka@gmail.com>2021-05-24 13:57:40 +0200
commit9ae7f793446115f4c818fbd2600524f21cced3f0 (patch)
tree2a5ff6ce69d9b5ee8f2f843af7f94d3182c56e09
parente6e9dd290698d47a0db9e1d676d2b82e0bb0a52b (diff)
downloadperl-9ae7f793446115f4c818fbd2600524f21cced3f0.tar.gz
Make use open :std push layers without any munging
Previously it would only apply the first layer that was either :utf8 or any other layer with and argument (e.g. :encoding(utf8)).
-rw-r--r--lib/open.pm21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/open.pm b/lib/open.pm
index 3e213816f9..86111ca864 100644
--- a/lib/open.pm
+++ b/lib/open.pm
@@ -1,7 +1,7 @@
package open;
use warnings;
-our $VERSION = '1.12';
+our $VERSION = '1.13';
require 5.008001; # for PerlIO::get_layers()
@@ -120,20 +120,11 @@ sub import {
${^OPEN} = join("\0", $in, $out);
if ($std) {
if ($in) {
- if ($in =~ /:utf8\b/) {
- binmode(STDIN, ":utf8");
- } elsif ($in =~ /(\w+\(.+\))/) {
- binmode(STDIN, ":$1");
- }
+ binmode STDIN, $in;
}
if ($out) {
- if ($out =~ /:utf8\b/) {
- binmode(STDOUT, ":utf8");
- binmode(STDERR, ":utf8");
- } elsif ($out =~ /(\w+\(.+\))/) {
- binmode(STDOUT, ":$1");
- binmode(STDERR, ":$1");
- }
+ binmode(STDOUT, $out);
+ binmode(STDERR, $out);
}
}
}
@@ -243,6 +234,10 @@ to this pragma in its own lexical scope.
{ use open ':std', IO => ':encoding(UTF-8)' }
+Before Perl 5.34, C<:std> would only apply the first layer provided that is
+either C<:utf8> or has a layer argument, e.g. C<:encoding(UTF-8)>. Since
+Perl 5.34 it will apply the same layer stack it provides to C<${^OPEN}>.
+
=head1 IMPLEMENTATION DETAILS
There is a class method in C<PerlIO::Layer> C<find> which is