When you use utf8::all, among other things it will:
Filehandles are opened with UTF-8 encoding turned on by default (including STDIN, STDOUT, and STDERR when utf8::all is used from the main package). Meaning that they automatically convert UTF-8 octets to characters and vice versa. If you don't want UTF-8 for a particular filehandle, you'll have to set binmode $filehandle.

This means it adds the utf8 layer on your STDIN. Your STDIN is reading binary data, and will die because that binary data is not utf-8. Your options are to call 'binmode STDIN' to un-apply the utf-8 layer from STDIN, or to not use utf8::all and choose between calling utf8::encode on your string before printing it, or manually adding the utf8 layer to STDOUT: binmode STDOUT, ":utf8".

FWIW, on Windows you would need to call binmode STDIN; regardless of whether you use utf8:all, because windows default is to convert \r\n line endings on STDIN. Your example is exactly why perl5 can't just change the defaults to make utf8::all automatic. Sometimes people do want to read binary data from stdin or write it to stdout, and on Unix they've never needed to call binmode before, because it's the default.


In reply to Re: Can't decode ill-formed UTF-8 octet sequence by NERDVANA
in thread Can't decode ill-formed UTF-8 octet sequence by Veraellyunjie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.