in reply to Difficulty with UTF-8 and file contents

There's no need to reopen the DATA handle, you can specify its encoding via binmode:
binmode *DATA, ':encoding(UTF-8)'; while (<DATA>) { # This populates $_ with decoded Unicode data, not b +ytes. ... )
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Difficulty with UTF-8 and file contents
by ikegami (Patriarch) on Apr 14, 2020 at 01:53 UTC

    That's useless. DATA, being the handle used by perl to read the source, is affected by the existing use utf8;.

    use if $ARGV[0], "utf8"; printf "%vX\n", scalar(<DATA>); __DATA__ é
    $ perl a.pl 0 C3.A9.A $ perl a.pl 1 E9.A

    The OP's problem appears to be a lack of encoding of the output, not a lack of decoding of the input.