Question

When I run this script I get 8 lines of output instead of 2.

#!perl
use strict;
use warnings;
use 5.10.1;

use PerlIO::encoding;
use Encode qw(:fallbacks);
$PerlIO::encoding::fallback = Encode::FB_HTMLCREF;
binmode STDOUT, ":encoding(cp850)";

say "TEST";
say "Hell\x{263a}\x{263b}llo.txt";

Output:

# TEST
# TEST
# Hell☺☻llo.txt
# TEST
# Hell☺☻llo.txt
# TEST
# Hell☺☻llo.txt
#

Why does this script output so many lines?

Was it helpful?

Solution

It's a really old bug: RT#40401. RT#29720 is probably the same bug, which makes it almost 10 years old. (And that's just when it was reported; I'd guess the bug dates back to when $PerlIO::encoding::fallback was first implemented.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top