in reply to When is the utf8-flag turned on?

v5.8.0 had some issues with its handling of UTF-8 that were fixed in 5.8.1. I would highly recommend upgrading, if possible. If not, here are some pointers to changes:

Also in the delta is this information about updates to the Encode module:

Significant updates on the encoding pragma functionality (tr/// and the DATA filehandle, formats).
If a filehandle has been marked as to have an encoding, unmappable characters are detected already during input, not later (when the corrupted data is being used).
...

Hope this helps