This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #96008] use and require are affected by the open pragma
authorBrian Fraser <fraserbn@gmail.com>
Fri, 23 Sep 2011 05:31:46 +0000 (22:31 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 23 Sep 2011 05:31:46 +0000 (22:31 -0700)
commit639dfab029654a3b066df400686e1acdaae62762
treef81d1af8a2e388554711e4a87393cd1ec7e334e6
parent69dc7e4bdb8e397c820e2a9d8685f676602362a6
[perl #96008] use and require are affected by the open pragma

% perl -e 'print "package F;\n # \xF1\n;1;"' > x.pl
% perl '-Mopen=:encoding(utf8)' -e 'require "x.pl"'
utf8 "\xF1" does not map to Unicode at x.pl line 1.

Bit of a surprising discovery; Turns out that passing a single ":" for
the layers skips the fetch from the context layers:
perl -wE 'use open qw( :encoding(UTF-8) ); open my $fh, "<:", "etc"; say PerlIO::get_layers($fh);'

That will only get the relevant default layers, while removing the
colons makes it work as usual -- So we can abuse this (mis)feature to
fix the bug.
pp_ctl.c