in reply to Re^3: replacement for deprecated encoding pragma
in thread replacement for deprecated encoding pragma

Although clearly not true, it is convenient to think of perl strings as "unencoded". By default, perl assumes that your source code is in LATIN-1. When your source is loaded, literal strings are 'decoded'. As long as your editor produces LATIN-1, you can use any character supported by LATIN-1 with no special Perl code. Likewise for I/O. Perl assumes that all input is LATIN-1 and decodes it. All output is encoded into LATIN-1. Today, we are often forced to deal with files encoded in utf-8. In new code, we use the pragma use utf8 to tell perl that the source code is in utf-8 (literal strings should be decoded from that rather than the default). We can specify I/O 'layers' on our I/O 'handles' to tell them to do the necessary encode/decode as part of I/O. We rarely need anything else. Older version of perl were quite different. Note that users of pure ASCII do not care about these issues because ASCII characters are encoded the same way in both schemes.
Bill

Replies are listed 'Best First'.
Re^5: replacement for deprecated encoding pragma
by ikegami (Patriarch) on Jul 22, 2021 at 04:20 UTC

    By default, perl assumes that your source code is in LATIN-1

    By default, perl assumes that your source code is in ASCII. (Though string literals are 8-bit clean.)

    $ printf 'use utf8; sub bête { } say "ok";' | perl -M5.010 ok $ printf 'sub bête { } say "ok";' | iconv -t iso-8859-1 | perl -M5.010 Illegal declaration of subroutine main::b at - line 1.

    Seeking work! You can reach me at ikegami@adaelis.com