Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Why does Perl choke on my UTF8 identifier?

by Anonymous Monk
on Mar 30, 2021 at 13:33 UTC ( #11130591=note: print w/replies, xml ) Need Help??

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 (Deacon) 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;


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11130591]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2021-05-07 11:30 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (91 votes). Check out past polls.