You are spreading (dangerous) FUD, no offence meant (really!). The bytes pragma works as advertised.

I agree, and it's not the right thing. It doesn't give the the number of bytes print will print. Everything else is moot.

The problem with your example is that you are fiddling with the internal UTF-8 flag.

Yes. Perl is free to do that whenever it wants. You can't count on it being in either state. If your solution requires it being off, you've got a bug.

The call to utf8::upgrade represents Perl changing the internal format of its string for whatever reason. I wouldn't actually use utf8::upgrade in that fashion, so your talk of it being a low-level function is moot. I could write the example without using utf8::upgrade, but I wanted to keep things simple.

Note that using use bytes; requires the use of those low-level functions, so it's low-level too.

The right way to UTF-8-encode a string is utf8::encode()

The program was suppose to output a sequence of 256 characters. You had to break it to make use bytes; work.

You might want to reread it; example [6] is especially interesting.

Indeed. It's the one where Perl told you had a bug, and you chose to fix the symptoms instead of the bug. It's also the only case where use bytes; helped. Are you saying that use bytes; only helps when Perl tells you you've made an error?

But, given the limited amount of information we have, my suggestion is still the best first step to take in solving the OP's problem.

Do you turn off use strict; and use warnings; when they start issuing messages? Solving the symptom (if not making things worse) is not the right first step.


In reply to Re^12: Determining content-length for an HTTP Post by ikegami
in thread Determining content-length for an HTTP Post by Anonymous Monk

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.