in reply to Why does Perl choke on my UTF8 identifier?

It is not enough just to say use utf8;. Your source file must actually be in utf-8 rather than some other encoding. When I download your sample and try to run it, I get the same compile errors you do. But when I edit it with vim and issue the vim :set fileencoding? command, it says fileencoding=latin1. When I :set fileencoding=utf-8 and save the file, the compile errors go away.

As kcott pointed out, you will also need to correct your use IO ... to get the output you want.

Replies are listed 'Best First'.
Re^2: Why does Perl choke on my UTF8 identifier?
by Intrepid (Curate) on Mar 30, 2021 at 20:20 UTC
    <meta http-equiv="Content-type" content="text/html;charset=cswindows1252">

    Aha! blaming the editor is correct. Your advice (Thank You!) was spot-on. I use vim too, and indeed, the fileencoding was set to iso-8859. I corrected that and ran the program successfully. I only feel a little under-educated. Effective Perl Programming should have had a note about editors and their codepages and how use utf8 won't dwim if the editor is saving the program text as something else ;-).

    Examine what is said, not who speaks.
    Love the truth but pardon error.
    Silence betokens consent.
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Wishful thinking on my part... aren't we long overdue to have editors default to UTF-8?

      use OldMan::Yelling::AtClouds;

      -bib